mirror of https://github.com/apache/lucene.git
SOLR-8750 : Use lambdas in code where SAM type interfaces are used
This commit is contained in:
parent
948a388778
commit
8d835f1231
|
@ -700,18 +700,15 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
|||
}
|
||||
|
||||
Collections.sort(expected,
|
||||
new Comparator<Input>() {
|
||||
@Override
|
||||
public int compare(Input a, Input b) {
|
||||
if (a.v > b.v) {
|
||||
return -1;
|
||||
} else if (a.v < b.v) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
(a1, b) -> {
|
||||
if (a1.v > b.v) {
|
||||
return -1;
|
||||
} else if (a1.v < b.v) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (expected.isEmpty() == false) {
|
||||
|
||||
|
|
|
@ -99,14 +99,10 @@ public class Assign {
|
|||
map.put(shardId, cnt);
|
||||
}
|
||||
|
||||
Collections.sort(shardIdNames, new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
Integer one = map.get(o1);
|
||||
Integer two = map.get(o2);
|
||||
return one.compareTo(two);
|
||||
}
|
||||
Collections.sort(shardIdNames, (o1, o2) -> {
|
||||
Integer one = map.get(o1);
|
||||
Integer two = map.get(o2);
|
||||
return one.compareTo(two);
|
||||
});
|
||||
|
||||
returnShardId = shardIdNames.get(0);
|
||||
|
@ -179,12 +175,7 @@ public class Assign {
|
|||
}
|
||||
|
||||
ArrayList<ReplicaCount> sortedNodeList = new ArrayList<>(nodeNameVsShardCount.values());
|
||||
Collections.sort(sortedNodeList, new Comparator<ReplicaCount>() {
|
||||
@Override
|
||||
public int compare(ReplicaCount x, ReplicaCount y) {
|
||||
return (x.weight() < y.weight()) ? -1 : ((x.weight() == y.weight()) ? 0 : 1);
|
||||
}
|
||||
});
|
||||
Collections.sort(sortedNodeList, (x, y) -> (x.weight() < y.weight()) ? -1 : ((x.weight() == y.weight()) ? 0 : 1));
|
||||
return sortedNodeList;
|
||||
|
||||
}
|
||||
|
|
|
@ -370,13 +370,9 @@ public class LeaderElector {
|
|||
* Sort n string sequence list.
|
||||
*/
|
||||
public static void sortSeqs(List<String> seqs) {
|
||||
Collections.sort(seqs, new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
int i = getSeq(o1) - getSeq(o2);
|
||||
return i == 0 ? o1.compareTo(o2) : i ;
|
||||
}
|
||||
Collections.sort(seqs, (o1, o2) -> {
|
||||
int i = getSeq(o1) - getSeq(o2);
|
||||
return i == 0 ? o1.compareTo(o2) : i;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -181,9 +181,7 @@ public class ZkCLI {
|
|||
SolrZkClient zkClient = null;
|
||||
try {
|
||||
zkClient = new SolrZkClient(zkServerAddress, 30000, 30000,
|
||||
new OnReconnect() {
|
||||
@Override
|
||||
public void command() {}
|
||||
() -> {
|
||||
});
|
||||
|
||||
if (line.getOptionValue(CMD).equalsIgnoreCase(BOOTSTRAP)) {
|
||||
|
|
|
@ -358,11 +358,8 @@ public final class ZkController {
|
|||
this.overseerCompletedMap = Overseer.getCompletedMap(zkClient);
|
||||
this.overseerFailureMap = Overseer.getFailureMap(zkClient);
|
||||
cmdExecutor = new ZkCmdExecutor(clientTimeout);
|
||||
zkStateReader = new ZkStateReader(zkClient, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(cc!=null) cc.securityNodeChanged();
|
||||
}
|
||||
zkStateReader = new ZkStateReader(zkClient, () -> {
|
||||
if (cc != null) cc.securityNodeChanged();
|
||||
});
|
||||
|
||||
this.baseURL = zkStateReader.getBaseUrlForNodeName(this.nodeName);
|
||||
|
@ -2402,14 +2399,11 @@ public final class ZkController {
|
|||
}
|
||||
|
||||
public OnReconnect getConfigDirListener() {
|
||||
return new OnReconnect() {
|
||||
@Override
|
||||
public void command() {
|
||||
synchronized (confDirectoryListeners) {
|
||||
for (String s : confDirectoryListeners.keySet()) {
|
||||
setConfWatcher(s, new WatcherImpl(s), null);
|
||||
fireEventListeners(s);
|
||||
}
|
||||
return () -> {
|
||||
synchronized (confDirectoryListeners) {
|
||||
for (String s : confDirectoryListeners.keySet()) {
|
||||
setConfWatcher(s, new WatcherImpl(s), null);
|
||||
fireEventListeners(s);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -210,28 +210,25 @@ public class ReplicaAssigner {
|
|||
int startPosition = 0;
|
||||
Map<String, Map<String, Integer>> copyOfCurrentState = getDeepCopy(shardVsNodes, 2);
|
||||
List<String> sortedLiveNodes = new ArrayList<>(this.participatingLiveNodes);
|
||||
Collections.sort(sortedLiveNodes, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String n1, String n2) {
|
||||
int result = 0;
|
||||
for (int i = 0; i < rulePermutation.length; i++) {
|
||||
Rule rule = rules.get(rulePermutation[i]);
|
||||
int val = rule.compare(n1, n2, nodeVsTagsCopy, copyOfCurrentState);
|
||||
if (val != 0) {//atleast one non-zero compare break now
|
||||
result = val;
|
||||
break;
|
||||
}
|
||||
if (result == 0) {//if all else is equal, prefer nodes with fewer cores
|
||||
AtomicInteger n1Count = nodeVsCores.get(n1);
|
||||
AtomicInteger n2Count = nodeVsCores.get(n2);
|
||||
int a = n1Count == null ? 0 : n1Count.get();
|
||||
int b = n2Count == null ? 0 : n2Count.get();
|
||||
result = a > b ? 1 : a == b ? 0 : -1;
|
||||
}
|
||||
|
||||
Collections.sort(sortedLiveNodes, (n1, n2) -> {
|
||||
int result1 = 0;
|
||||
for (int i = 0; i < rulePermutation.length; i++) {
|
||||
Rule rule = rules.get(rulePermutation[i]);
|
||||
int val = rule.compare(n1, n2, nodeVsTagsCopy, copyOfCurrentState);
|
||||
if (val != 0) {//atleast one non-zero compare break now
|
||||
result1 = val;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
if (result1 == 0) {//if all else is equal, prefer nodes with fewer cores
|
||||
AtomicInteger n1Count = nodeVsCores.get(n1);
|
||||
AtomicInteger n2Count = nodeVsCores.get(n2);
|
||||
int a = n1Count == null ? 0 : n1Count.get();
|
||||
int b = n2Count == null ? 0 : n2Count.get();
|
||||
result1 = a > b ? 1 : a == b ? 0 : -1;
|
||||
}
|
||||
|
||||
}
|
||||
return result1;
|
||||
});
|
||||
forEachPosition:
|
||||
for (Position position : positions) {
|
||||
|
|
|
@ -2530,46 +2530,43 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
|
|||
schemaRes = mis.getResourceName();
|
||||
}
|
||||
final String managedSchmaResourcePath = schemaRes == null ? null : zkSolrResourceLoader.getConfigSetZkPath() + "/" + schemaRes;
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log.info("config update listener called for core {}", coreName);
|
||||
SolrZkClient zkClient = cc.getZkController().getZkClient();
|
||||
int solrConfigversion, overlayVersion, managedSchemaVersion = 0;
|
||||
SolrConfig cfg = null;
|
||||
try (SolrCore core = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
||||
if (core == null || core.isClosed()) return;
|
||||
cfg = core.getSolrConfig();
|
||||
solrConfigversion = core.getSolrConfig().getOverlay().getZnodeVersion();
|
||||
overlayVersion = core.getSolrConfig().getZnodeVersion();
|
||||
if (managedSchmaResourcePath != null) {
|
||||
managedSchemaVersion = ((ManagedIndexSchema) core.getLatestSchema()).getSchemaZkVersion();
|
||||
}
|
||||
|
||||
}
|
||||
if (cfg != null) {
|
||||
cfg.refreshRequestParams();
|
||||
}
|
||||
if (checkStale(zkClient, overlayPath, solrConfigversion) ||
|
||||
checkStale(zkClient, solrConfigPath, overlayVersion) ||
|
||||
checkStale(zkClient, managedSchmaResourcePath, managedSchemaVersion)) {
|
||||
log.info("core reload {}", coreName);
|
||||
cc.reload(coreName);
|
||||
return;
|
||||
}
|
||||
//some files in conf directory may have other than managedschema, overlay, params
|
||||
try (SolrCore core = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
||||
if (core == null || core.isClosed()) return;
|
||||
for (Runnable listener : core.confListeners) {
|
||||
try {
|
||||
listener.run();
|
||||
} catch (Exception e) {
|
||||
log.error("Error in listener ", e);
|
||||
}
|
||||
}
|
||||
return () -> {
|
||||
log.info("config update listener called for core {}", coreName);
|
||||
SolrZkClient zkClient = cc.getZkController().getZkClient();
|
||||
int solrConfigversion, overlayVersion, managedSchemaVersion = 0;
|
||||
SolrConfig cfg = null;
|
||||
try (SolrCore core1 = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
||||
if (core1 == null || core1.isClosed()) return;
|
||||
cfg = core1.getSolrConfig();
|
||||
solrConfigversion = core1.getSolrConfig().getOverlay().getZnodeVersion();
|
||||
overlayVersion = core1.getSolrConfig().getZnodeVersion();
|
||||
if (managedSchmaResourcePath != null) {
|
||||
managedSchemaVersion = ((ManagedIndexSchema) core1.getLatestSchema()).getSchemaZkVersion();
|
||||
}
|
||||
|
||||
}
|
||||
if (cfg != null) {
|
||||
cfg.refreshRequestParams();
|
||||
}
|
||||
if (checkStale(zkClient, overlayPath, solrConfigversion) ||
|
||||
checkStale(zkClient, solrConfigPath, overlayVersion) ||
|
||||
checkStale(zkClient, managedSchmaResourcePath, managedSchemaVersion)) {
|
||||
log.info("core reload {}", coreName);
|
||||
cc.reload(coreName);
|
||||
return;
|
||||
}
|
||||
//some files in conf directory may have other than managedschema, overlay, params
|
||||
try (SolrCore core1 = cc.solrCores.getCoreFromAnyList(coreName, true)) {
|
||||
if (core1 == null || core1.isClosed()) return;
|
||||
for (Runnable listener : core1.confListeners) {
|
||||
try {
|
||||
listener.run();
|
||||
} catch (Exception e) {
|
||||
log.error("Error in listener ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -68,32 +68,27 @@ class CdcrReplicatorScheduler {
|
|||
|
||||
// the scheduler thread is executed every second and submits one replication task
|
||||
// per available state in the queue
|
||||
scheduler.scheduleWithFixedDelay(new Runnable() {
|
||||
scheduler.scheduleWithFixedDelay(() -> {
|
||||
int nCandidates = statesQueue.size();
|
||||
for (int i = 0; i < nCandidates; i++) {
|
||||
// a thread that poll one state from the queue, execute the replication task, and push back
|
||||
// the state in the queue when the task is completed
|
||||
replicatorsPool.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int nCandidates = statesQueue.size();
|
||||
for (int i = 0; i < nCandidates; i++) {
|
||||
// a thread that poll one state from the queue, execute the replication task, and push back
|
||||
// the state in the queue when the task is completed
|
||||
replicatorsPool.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
CdcrReplicatorState state = statesQueue.poll();
|
||||
assert state != null; // Should never happen
|
||||
try {
|
||||
new CdcrReplicator(state, batchSize).run();
|
||||
} finally {
|
||||
statesQueue.offer(state);
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
CdcrReplicatorState state = statesQueue.poll();
|
||||
assert state != null; // Should never happen
|
||||
try {
|
||||
new CdcrReplicator(state, batchSize).run();
|
||||
} finally {
|
||||
statesQueue.offer(state);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}, 0, timeSchedule, TimeUnit.MILLISECONDS);
|
||||
isStarted = true;
|
||||
}
|
||||
|
|
|
@ -1452,14 +1452,11 @@ public class IndexFetcher {
|
|||
} finally {
|
||||
cleanup();
|
||||
//if cleanup succeeds . The file is downloaded fully. do an fsync
|
||||
fsyncService.submit(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
file.sync();
|
||||
} catch (IOException e) {
|
||||
fsyncException = e;
|
||||
}
|
||||
fsyncService.submit(() -> {
|
||||
try {
|
||||
file.sync();
|
||||
} catch (IOException e) {
|
||||
fsyncException = e;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1077,20 +1077,17 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
|||
return;
|
||||
}
|
||||
|
||||
Runnable task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (pollDisabled.get()) {
|
||||
LOG.info("Poll disabled");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LOG.debug("Polling for index modifications");
|
||||
markScheduledExecutionStart();
|
||||
doFetch(null, false);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in fetching index", e);
|
||||
}
|
||||
Runnable task = () -> {
|
||||
if (pollDisabled.get()) {
|
||||
LOG.info("Poll disabled");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LOG.debug("Polling for index modifications");
|
||||
markScheduledExecutionStart();
|
||||
doFetch(null, false);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in fetching index", e);
|
||||
}
|
||||
};
|
||||
executorService = Executors.newSingleThreadScheduledExecutor(
|
||||
|
|
|
@ -155,23 +155,20 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
try {
|
||||
MDC.put("CoreAdminHandler.asyncId", taskId);
|
||||
MDC.put("CoreAdminHandler.action", op.action.toString());
|
||||
parallelExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean exceptionCaught = false;
|
||||
try {
|
||||
callInfo.call();
|
||||
taskObject.setRspObject(callInfo.rsp);
|
||||
} catch (Exception e) {
|
||||
exceptionCaught = true;
|
||||
taskObject.setRspObjectFromException(e);
|
||||
} finally {
|
||||
removeTask("running", taskObject.taskId);
|
||||
if (exceptionCaught) {
|
||||
addTask("failed", taskObject, true);
|
||||
} else
|
||||
addTask("completed", taskObject, true);
|
||||
}
|
||||
parallelExecutor.execute(() -> {
|
||||
boolean exceptionCaught = false;
|
||||
try {
|
||||
callInfo.call();
|
||||
taskObject.setRspObject(callInfo.rsp);
|
||||
} catch (Exception e) {
|
||||
exceptionCaught = true;
|
||||
taskObject.setRspObjectFromException(e);
|
||||
} finally {
|
||||
removeTask("running", taskObject.taskId);
|
||||
if (exceptionCaught) {
|
||||
addTask("failed", taskObject, true);
|
||||
} else
|
||||
addTask("completed", taskObject, true);
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
|
|
|
@ -1448,12 +1448,7 @@ public class FacetComponent extends SearchComponent {
|
|||
public ShardFacetCount[] getLexSorted() {
|
||||
ShardFacetCount[] arr
|
||||
= counts.values().toArray(new ShardFacetCount[counts.size()]);
|
||||
Arrays.sort(arr, new Comparator<ShardFacetCount>() {
|
||||
@Override
|
||||
public int compare(ShardFacetCount o1, ShardFacetCount o2) {
|
||||
return o1.indexed.compareTo(o2.indexed);
|
||||
}
|
||||
});
|
||||
Arrays.sort(arr, (o1, o2) -> o1.indexed.compareTo(o2.indexed));
|
||||
countSorted = arr;
|
||||
return arr;
|
||||
}
|
||||
|
@ -1461,13 +1456,10 @@ public class FacetComponent extends SearchComponent {
|
|||
public ShardFacetCount[] getCountSorted() {
|
||||
ShardFacetCount[] arr
|
||||
= counts.values().toArray(new ShardFacetCount[counts.size()]);
|
||||
Arrays.sort(arr, new Comparator<ShardFacetCount>() {
|
||||
@Override
|
||||
public int compare(ShardFacetCount o1, ShardFacetCount o2) {
|
||||
if (o2.count < o1.count) return -1;
|
||||
else if (o1.count < o2.count) return 1;
|
||||
return o1.indexed.compareTo(o2.indexed);
|
||||
}
|
||||
Arrays.sort(arr, (o1, o2) -> {
|
||||
if (o2.count < o1.count) return -1;
|
||||
else if (o1.count < o2.count) return 1;
|
||||
return o1.indexed.compareTo(o2.indexed);
|
||||
});
|
||||
countSorted = arr;
|
||||
return arr;
|
||||
|
|
|
@ -66,12 +66,10 @@ public interface MergeStrategy {
|
|||
* */
|
||||
public int getCost();
|
||||
|
||||
public static final Comparator MERGE_COMP = new Comparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
MergeStrategy m1 = (MergeStrategy)o1;
|
||||
MergeStrategy m2 = (MergeStrategy)o2;
|
||||
return m1.getCost()-m2.getCost();
|
||||
}
|
||||
};
|
||||
final Comparator MERGE_COMP = (o1, o2) -> {
|
||||
MergeStrategy m1 = (MergeStrategy) o1;
|
||||
MergeStrategy m2 = (MergeStrategy) o2;
|
||||
return m1.getCost() - m2.getCost();
|
||||
};
|
||||
|
||||
}
|
|
@ -104,7 +104,15 @@ public class ShardFieldSortedHitQueue extends PriorityQueue<ShardDoc> {
|
|||
Comparator<ShardDoc> getCachedComparator(SortField sortField, IndexSearcher searcher) {
|
||||
SortField.Type type = sortField.getType();
|
||||
if (type == SortField.Type.SCORE) {
|
||||
return comparatorScore();
|
||||
return (o1, o2) -> {
|
||||
final float f1 = o1.score;
|
||||
final float f2 = o2.score;
|
||||
if (f1 < f2)
|
||||
return -1;
|
||||
if (f1 > f2)
|
||||
return 1;
|
||||
return 0;
|
||||
};
|
||||
} else if (type == SortField.Type.REWRITEABLE) {
|
||||
try {
|
||||
sortField = sortField.rewrite(searcher);
|
||||
|
@ -140,21 +148,6 @@ public class ShardFieldSortedHitQueue extends PriorityQueue<ShardDoc> {
|
|||
}
|
||||
}
|
||||
|
||||
static Comparator<ShardDoc> comparatorScore() {
|
||||
return new Comparator<ShardDoc>() {
|
||||
@Override
|
||||
public final int compare(final ShardDoc o1, final ShardDoc o2) {
|
||||
final float f1 = o1.score;
|
||||
final float f2 = o2.score;
|
||||
if (f1 < f2)
|
||||
return -1;
|
||||
if (f1 > f2)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Comparator<ShardDoc> comparatorFieldComparator(SortField sortField) {
|
||||
final FieldComparator fieldComparator;
|
||||
try {
|
||||
|
|
|
@ -441,12 +441,7 @@ public class TermsComponent extends SearchComponent {
|
|||
public TermsResponse.Term[] getLexSorted(HashMap<String, TermsResponse.Term> data) {
|
||||
TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
|
||||
|
||||
Arrays.sort(arr, new Comparator<TermsResponse.Term>() {
|
||||
@Override
|
||||
public int compare(TermsResponse.Term o1, TermsResponse.Term o2) {
|
||||
return o1.getTerm().compareTo(o2.getTerm());
|
||||
}
|
||||
});
|
||||
Arrays.sort(arr, (o1, o2) -> o1.getTerm().compareTo(o2.getTerm()));
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
@ -455,19 +450,16 @@ public class TermsComponent extends SearchComponent {
|
|||
public TermsResponse.Term[] getCountSorted(HashMap<String, TermsResponse.Term> data) {
|
||||
TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
|
||||
|
||||
Arrays.sort(arr, new Comparator<TermsResponse.Term>() {
|
||||
@Override
|
||||
public int compare(TermsResponse.Term o1, TermsResponse.Term o2) {
|
||||
long freq1 = o1.getFrequency();
|
||||
long freq2 = o2.getFrequency();
|
||||
|
||||
if (freq2 < freq1) {
|
||||
return -1;
|
||||
} else if (freq1 < freq2) {
|
||||
return 1;
|
||||
} else {
|
||||
return o1.getTerm().compareTo(o2.getTerm());
|
||||
}
|
||||
Arrays.sort(arr, (o1, o2) -> {
|
||||
long freq1 = o1.getFrequency();
|
||||
long freq2 = o2.getFrequency();
|
||||
|
||||
if (freq2 < freq1) {
|
||||
return -1;
|
||||
} else if (freq1 < freq2) {
|
||||
return 1;
|
||||
} else {
|
||||
return o1.getTerm().compareTo(o2.getTerm());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -613,12 +613,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
|
|||
if (frags.size() > 0) {
|
||||
// sort such that the fragments with the highest score come first
|
||||
if (!preserveMulti) {
|
||||
Collections.sort(frags, new Comparator<TextFragment>() {//TODO make TextFragment Comparable
|
||||
@Override
|
||||
public int compare(TextFragment arg0, TextFragment arg1) {
|
||||
return Float.compare(arg1.getScore(), arg0.getScore());
|
||||
}
|
||||
});
|
||||
Collections.sort(frags, (arg0, arg1) -> Float.compare(arg1.getScore(), arg0.getScore()));
|
||||
}
|
||||
|
||||
// Truncate list to hl.snippets, but not when hl.preserveMulti
|
||||
|
|
|
@ -1410,12 +1410,9 @@ public class IndexSchema {
|
|||
SortedMap<String,List<CopyField>> sortedCopyFields = new TreeMap<>(copyFieldsMap);
|
||||
for (List<CopyField> copyFields : sortedCopyFields.values()) {
|
||||
copyFields = new ArrayList<>(copyFields);
|
||||
Collections.sort(copyFields, new Comparator<CopyField>() {
|
||||
@Override
|
||||
public int compare(CopyField cf1, CopyField cf2) {
|
||||
// sources are all the same, just sorting by destination here
|
||||
return cf1.getDestination().getName().compareTo(cf2.getDestination().getName());
|
||||
}
|
||||
Collections.sort(copyFields, (cf1, cf2) -> {
|
||||
// sources are all the same, just sorting by destination here
|
||||
return cf1.getDestination().getName().compareTo(cf2.getDestination().getName());
|
||||
});
|
||||
for (CopyField copyField : copyFields) {
|
||||
final String source = copyField.getSource().getName();
|
||||
|
|
|
@ -1068,12 +1068,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
|
|||
public boolean hasDeletedDocs; // true if it's possible that filter may match deleted docs
|
||||
}
|
||||
|
||||
private static Comparator<Query> sortByCost = new Comparator<Query>() {
|
||||
@Override
|
||||
public int compare(Query q1, Query q2) {
|
||||
return ((ExtendedQuery) q1).getCost() - ((ExtendedQuery) q2).getCost();
|
||||
}
|
||||
};
|
||||
private static Comparator<Query> sortByCost = (q1, q2) -> ((ExtendedQuery) q1).getCost() - ((ExtendedQuery) q2).getCost();
|
||||
|
||||
private DocSet getDocSetScore(List<Query> queries) throws IOException {
|
||||
Query main = queries.remove(0);
|
||||
|
|
|
@ -532,21 +532,13 @@ class FacetFieldMerger extends FacetBucketMerger<FacetField> {
|
|||
final int sortMul = direction.getMultiplier();
|
||||
|
||||
if ("count".equals(freq.sortVariable)) {
|
||||
comparator = new Comparator<FacetBucket>() {
|
||||
@Override
|
||||
public int compare(FacetBucket o1, FacetBucket o2) {
|
||||
int v = -Long.compare(o1.count, o2.count) * sortMul;
|
||||
return v == 0 ? o1.bucketValue.compareTo(o2.bucketValue) : v;
|
||||
}
|
||||
comparator = (o1, o2) -> {
|
||||
int v = -Long.compare(o1.count, o2.count) * sortMul;
|
||||
return v == 0 ? o1.bucketValue.compareTo(o2.bucketValue) : v;
|
||||
};
|
||||
Collections.sort(sortedBuckets, comparator);
|
||||
} else if ("index".equals(freq.sortVariable)) {
|
||||
comparator = new Comparator<FacetBucket>() {
|
||||
@Override
|
||||
public int compare(FacetBucket o1, FacetBucket o2) {
|
||||
return -o1.bucketValue.compareTo(o2.bucketValue) * sortMul;
|
||||
}
|
||||
};
|
||||
comparator = (o1, o2) -> -o1.bucketValue.compareTo(o2.bucketValue) * sortMul;
|
||||
Collections.sort(sortedBuckets, comparator);
|
||||
} else {
|
||||
final String key = freq.sortVariable;
|
||||
|
@ -598,12 +590,7 @@ class FacetFieldMerger extends FacetBucketMerger<FacetField> {
|
|||
}
|
||||
}
|
||||
Collections.sort(lst);
|
||||
Collections.sort(nulls, new Comparator<FacetBucket>() {
|
||||
@Override
|
||||
public int compare(FacetBucket o1, FacetBucket o2) {
|
||||
return o1.bucketValue.compareTo(o2.bucketValue);
|
||||
}
|
||||
});
|
||||
Collections.sort(nulls, (o1, o2) -> o1.bucketValue.compareTo(o2.bucketValue));
|
||||
|
||||
ArrayList<FacetBucket> out = new ArrayList<>(buckets.size());
|
||||
for (SortVal sv : lst) {
|
||||
|
|
|
@ -86,34 +86,28 @@ public class PeerSync {
|
|||
private SolrCore core;
|
||||
|
||||
// comparator that sorts by absolute value, putting highest first
|
||||
private static Comparator<Long> absComparator = new Comparator<Long>() {
|
||||
@Override
|
||||
public int compare(Long o1, Long o2) {
|
||||
long l1 = Math.abs(o1);
|
||||
long l2 = Math.abs(o2);
|
||||
if (l1 >l2) return -1;
|
||||
if (l1 < l2) return 1;
|
||||
return 0;
|
||||
}
|
||||
private static Comparator<Long> absComparator = (o1, o2) -> {
|
||||
long l1 = Math.abs(o1);
|
||||
long l2 = Math.abs(o2);
|
||||
if (l1 > l2) return -1;
|
||||
if (l1 < l2) return 1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
// comparator that sorts update records by absolute value of version, putting lowest first
|
||||
private static Comparator<Object> updateRecordComparator = new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (!(o1 instanceof List)) return 1;
|
||||
if (!(o2 instanceof List)) return -1;
|
||||
private static Comparator<Object> updateRecordComparator = (o1, o2) -> {
|
||||
if (!(o1 instanceof List)) return 1;
|
||||
if (!(o2 instanceof List)) return -1;
|
||||
|
||||
List lst1 = (List)o1;
|
||||
List lst2 = (List)o2;
|
||||
List lst1 = (List) o1;
|
||||
List lst2 = (List) o2;
|
||||
|
||||
long l1 = Math.abs((Long)lst1.get(1));
|
||||
long l2 = Math.abs((Long)lst2.get(1));
|
||||
long l1 = Math.abs((Long) lst1.get(1));
|
||||
long l2 = Math.abs((Long) lst2.get(1));
|
||||
|
||||
if (l1 >l2) return 1;
|
||||
if (l1 < l2) return -1;
|
||||
return 0;
|
||||
}
|
||||
if (l1 > l2) return 1;
|
||||
if (l1 < l2) return -1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -500,11 +500,7 @@ public final class DocExpirationUpdateProcessorFactory
|
|||
/** @see #iAmInChargeOfPeriodicDeletes */
|
||||
private volatile boolean previouslyInChargeOfDeletes = true;
|
||||
|
||||
private static final Comparator<Slice> COMPARE_SLICES_BY_NAME = new Comparator<Slice>() {
|
||||
public int compare(Slice a, Slice b) {
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
};
|
||||
private static final Comparator<Slice> COMPARE_SLICES_BY_NAME = (a, b) -> a.getName().compareTo(b.getName());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -208,13 +208,7 @@ public class DistributedIntervalFacetingTest extends
|
|||
values[0] = random().nextInt(max);
|
||||
values[1] = random().nextInt(max);
|
||||
if ("test_s_dv".equals(fieldName) || "test_ss_dv".equals(fieldName)) {
|
||||
Arrays.sort(values, new Comparator<Integer>() {
|
||||
|
||||
@Override
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
return String.valueOf(o1).compareTo(String.valueOf(o2));
|
||||
}
|
||||
});
|
||||
Arrays.sort(values, (o1, o2) -> String.valueOf(o1).compareTo(String.valueOf(o2)));
|
||||
} else {
|
||||
Arrays.sort(values);
|
||||
}
|
||||
|
|
|
@ -915,26 +915,20 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
|
|||
|
||||
|
||||
public static Comparator<Grp> createMaxDocComparator(final Comparator<Doc> docComparator) {
|
||||
return new Comparator<Grp>() {
|
||||
@Override
|
||||
public int compare(Grp o1, Grp o2) {
|
||||
// all groups should have at least one doc
|
||||
Doc d1 = o1.maxDoc;
|
||||
Doc d2 = o2.maxDoc;
|
||||
return docComparator.compare(d1, d2);
|
||||
}
|
||||
return (o1, o2) -> {
|
||||
// all groups should have at least one doc
|
||||
Doc d1 = o1.maxDoc;
|
||||
Doc d2 = o2.maxDoc;
|
||||
return docComparator.compare(d1, d2);
|
||||
};
|
||||
}
|
||||
|
||||
public static Comparator<Grp> createFirstDocComparator(final Comparator<Doc> docComparator) {
|
||||
return new Comparator<Grp>() {
|
||||
@Override
|
||||
public int compare(Grp o1, Grp o2) {
|
||||
// all groups should have at least one doc
|
||||
Doc d1 = o1.docs.get(0);
|
||||
Doc d2 = o2.docs.get(0);
|
||||
return docComparator.compare(d1, d2);
|
||||
}
|
||||
return (o1, o2) -> {
|
||||
// all groups should have at least one doc
|
||||
Doc d1 = o1.docs.get(0);
|
||||
Doc d2 = o2.docs.get(0);
|
||||
return docComparator.compare(d1, d2);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -568,25 +568,20 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
ThreadPoolExecutor executor, final String collection, final int numShards, int cnt) {
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
final int freezeI = i;
|
||||
executor.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Create createCmd = new Create();
|
||||
createCmd.setCoreName(collection + freezeI);
|
||||
createCmd.setCollection(collection);
|
||||
executor.execute(() -> {
|
||||
Create createCmd = new Create();
|
||||
createCmd.setCoreName(collection + freezeI);
|
||||
createCmd.setCollection(collection);
|
||||
|
||||
createCmd.setNumShards(numShards);
|
||||
try {
|
||||
String core3dataDir = createTempDir(collection).toFile().getAbsolutePath();
|
||||
createCmd.setDataDir(getDataDir(core3dataDir));
|
||||
createCmd.setNumShards(numShards);
|
||||
try {
|
||||
String core3dataDir = createTempDir(collection).toFile().getAbsolutePath();
|
||||
createCmd.setDataDir(getDataDir(core3dataDir));
|
||||
|
||||
client.request(createCmd);
|
||||
} catch (SolrServerException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
client.request(createCmd);
|
||||
} catch (SolrServerException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,13 +145,10 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
|
|||
|
||||
this.es = es;
|
||||
if (this.es == null) {
|
||||
this.es = new ElectorSetup(new OnReconnect() {
|
||||
@Override
|
||||
public void command() {
|
||||
try {
|
||||
setupOnConnect();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
this.es = new ElectorSetup(() -> {
|
||||
try {
|
||||
setupOnConnect();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -413,22 +413,18 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
|||
//register total of coreCount cores
|
||||
for (int i = 0; i < coreCount; i++) {
|
||||
final int slot = i;
|
||||
Runnable coreStarter = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final String coreName = "core" + slot;
|
||||
|
||||
try {
|
||||
ids[slot]=controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, Replica.State.ACTIVE, sliceCount);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail("register threw exception:" + e.getClass());
|
||||
}
|
||||
nodeExecutors[i % nodeCount].submit((Runnable) () -> {
|
||||
|
||||
final String coreName = "core" + slot;
|
||||
|
||||
try {
|
||||
ids[slot] = controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, Replica.State.ACTIVE, sliceCount);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail("register threw exception:" + e.getClass());
|
||||
}
|
||||
};
|
||||
|
||||
nodeExecutors[i % nodeCount].submit(coreStarter);
|
||||
});
|
||||
}
|
||||
|
||||
for (int i = 0; i < nodeCount; i++) {
|
||||
|
|
|
@ -108,12 +108,10 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
|
|||
}));
|
||||
|
||||
// force a deterministic random ordering of the files so seeds reproduce regardless of platform/filesystem
|
||||
Collections.sort(xmlFiles, new Comparator<File>() {
|
||||
public int compare(File o1, File o2) {
|
||||
// don't rely on File.compareTo, it's behavior varies by OS
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
Collections.sort(xmlFiles, (o1, o2) -> {
|
||||
// don't rely on File.compareTo, it's behavior varies by OS
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
});
|
||||
Collections.shuffle(xmlFiles, new Random(random().nextLong()));
|
||||
|
||||
// if you add/remove example XML docs, you'll have to fix these expected values
|
||||
|
|
|
@ -407,16 +407,13 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
|
|||
try {
|
||||
for (int j = 0; j < cnt; j++) {
|
||||
final int freezeJ = j;
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Unload unloadCmd = new Unload(true);
|
||||
unloadCmd.setCoreName("multiunload" + freezeJ);
|
||||
try {
|
||||
adminClient.request(unloadCmd);
|
||||
} catch (SolrServerException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
executor.execute(() -> {
|
||||
Unload unloadCmd = new Unload(true);
|
||||
unloadCmd.setCoreName("multiunload" + freezeJ);
|
||||
try {
|
||||
adminClient.request(unloadCmd);
|
||||
} catch (SolrServerException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
Thread.sleep(random().nextInt(50));
|
||||
|
|
|
@ -351,13 +351,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
|
|||
values[0] = random().nextInt(max);
|
||||
values[1] = random().nextInt(max);
|
||||
if (fieldName.startsWith("test_s")) {
|
||||
Arrays.sort(values, new Comparator<Integer>() {
|
||||
|
||||
@Override
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
return String.valueOf(o1).compareTo(String.valueOf(o2));
|
||||
}
|
||||
});
|
||||
Arrays.sort(values, (o1, o2) -> String.valueOf(o1).compareTo(String.valueOf(o2)));
|
||||
} else {
|
||||
Arrays.sort(values);
|
||||
}
|
||||
|
|
|
@ -385,14 +385,11 @@ public class TestLFUCache extends SolrTestCaseJ4 {
|
|||
* design, the cache eviction doesn't work right.
|
||||
*/
|
||||
for (int i = 0; i < atLeast(2_000_000); ++i) {
|
||||
executorService.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
cache.put(random().nextInt(100), random().nextLong());
|
||||
} catch (Throwable t) {
|
||||
error.compareAndSet(null, t);
|
||||
}
|
||||
executorService.submit(() -> {
|
||||
try {
|
||||
cache.put(random().nextInt(100), random().nextLong());
|
||||
} catch (Throwable t) {
|
||||
error.compareAndSet(null, t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -270,16 +270,13 @@ public class TestRankQueryPlugin extends QParserPlugin {
|
|||
} // end for-each-doc-in-response
|
||||
} // end for-each-response
|
||||
|
||||
Collections.sort(shardDocs, new Comparator<ShardDoc>() {
|
||||
@Override
|
||||
public int compare(ShardDoc o1, ShardDoc o2) {
|
||||
if(o1.score < o2.score) {
|
||||
return 1;
|
||||
} else if (o1.score > o2.score) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
Collections.sort(shardDocs, (o1, o2) -> {
|
||||
if (o1.score < o2.score) {
|
||||
return 1;
|
||||
} else if (o1.score > o2.score) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -591,16 +588,13 @@ public class TestRankQueryPlugin extends QParserPlugin {
|
|||
} // end for-each-doc-in-response
|
||||
} // end for-each-response
|
||||
|
||||
Collections.sort(shardDocs, new Comparator<ShardDoc>() {
|
||||
@Override
|
||||
public int compare(ShardDoc o1, ShardDoc o2) {
|
||||
if(o1.score < o2.score) {
|
||||
return 1;
|
||||
} else if (o1.score > o2.score) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
Collections.sort(shardDocs, (o1, o2) -> {
|
||||
if (o1.score < o2.score) {
|
||||
return 1;
|
||||
} else if (o1.score > o2.score) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -93,23 +93,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
clearIndex();
|
||||
|
@ -197,14 +189,11 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -359,23 +348,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -495,23 +476,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -632,12 +605,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
DirectUpdateHandler2.commitOnClose = false;
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -762,23 +730,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -827,23 +787,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
clearIndex();
|
||||
|
@ -959,23 +911,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
|
||||
File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());
|
||||
|
@ -1098,23 +1042,15 @@ public class TestRecovery extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
|
||||
File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());
|
||||
|
|
|
@ -153,23 +153,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
clearIndex();
|
||||
|
@ -257,23 +249,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -420,23 +404,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -556,12 +532,7 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
DirectUpdateHandler2.commitOnClose = false;
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -686,23 +657,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
|
||||
SolrQueryRequest req = req();
|
||||
|
@ -751,14 +714,11 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -867,23 +827,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
|
||||
|
||||
|
@ -1006,23 +958,15 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
|
||||
|
||||
|
|
|
@ -299,25 +299,22 @@ public class TestSort extends SolrTestCaseJ4 {
|
|||
|
||||
searcher.search(filt, myCollector);
|
||||
|
||||
Collections.sort(collectedDocs, new Comparator<MyDoc>() {
|
||||
@Override
|
||||
public int compare(MyDoc o1, MyDoc o2) {
|
||||
String v1 = o1.val==null ? nullRep : o1.val;
|
||||
String v2 = o2.val==null ? nullRep : o2.val;
|
||||
int cmp = v1.compareTo(v2);
|
||||
if (reverse) cmp = -cmp;
|
||||
if (cmp != 0) return cmp;
|
||||
Collections.sort(collectedDocs, (o1, o2) -> {
|
||||
String v1 = o1.val == null ? nullRep : o1.val;
|
||||
String v2 = o2.val == null ? nullRep : o2.val;
|
||||
int cmp = v1.compareTo(v2);
|
||||
if (reverse) cmp = -cmp;
|
||||
if (cmp != 0) return cmp;
|
||||
|
||||
if (secondary) {
|
||||
v1 = o1.val2==null ? nullRep2 : o1.val2;
|
||||
v2 = o2.val2==null ? nullRep2 : o2.val2;
|
||||
cmp = v1.compareTo(v2);
|
||||
if (reverse2) cmp = -cmp;
|
||||
}
|
||||
|
||||
cmp = cmp==0 ? o1.doc-o2.doc : cmp;
|
||||
return cmp;
|
||||
if (secondary) {
|
||||
v1 = o1.val2 == null ? nullRep2 : o1.val2;
|
||||
v2 = o2.val2 == null ? nullRep2 : o2.val2;
|
||||
cmp = v1.compareTo(v2);
|
||||
if (reverse2) cmp = -cmp;
|
||||
}
|
||||
|
||||
cmp = cmp == 0 ? o1.doc - o2.doc : cmp;
|
||||
return cmp;
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -148,12 +148,9 @@ public class TestJsonFacets extends SolrTestCaseHS {
|
|||
for (int i=0; i<honda_model_counts.length-1; i++) {
|
||||
idx.add(i);
|
||||
}
|
||||
Collections.sort(idx, new Comparator<Integer>() {
|
||||
@Override
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
int cmp = honda_model_counts[o2] - honda_model_counts[o1];
|
||||
return cmp == 0 ? o1 - o2 : cmp;
|
||||
}
|
||||
Collections.sort(idx, (o1, o2) -> {
|
||||
int cmp = honda_model_counts[o2] - honda_model_counts[o1];
|
||||
return cmp == 0 ? o1 - o2 : cmp;
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -175,12 +175,9 @@ public class TestScoreJoinQPScore extends SolrTestCaseJ4 {
|
|||
|
||||
}
|
||||
|
||||
final static Comparator<String> lessFloat = new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
assertTrue(Float.parseFloat(o1) < Float.parseFloat(o2));
|
||||
return 0;
|
||||
}
|
||||
final static Comparator<String> lessFloat = (o1, o2) -> {
|
||||
assertTrue(Float.parseFloat(o1) < Float.parseFloat(o2));
|
||||
return 0;
|
||||
};
|
||||
|
||||
@Ignore("SOLR-7814, also don't forget cover boost at testCacheHit()")
|
||||
|
|
|
@ -436,23 +436,15 @@ public class CdcrUpdateLogTest extends SolrTestCaseJ4 {
|
|||
final Semaphore logReplay = new Semaphore(0);
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
|
||||
UpdateLog.testing_logReplayHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UpdateLog.testing_logReplayHook = () -> {
|
||||
try {
|
||||
assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
Deque<Long> versions = new ArrayDeque<>();
|
||||
versions.addFirst(addAndGetVersion(sdoc("id", "A11"), null));
|
||||
|
@ -668,12 +660,7 @@ public class CdcrUpdateLogTest extends SolrTestCaseJ4 {
|
|||
try {
|
||||
DirectUpdateHandler2.commitOnClose = false;
|
||||
final Semaphore logReplayFinish = new Semaphore(0);
|
||||
UpdateLog.testing_logReplayFinishHook = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logReplayFinish.release();
|
||||
}
|
||||
};
|
||||
UpdateLog.testing_logReplayFinishHook = () -> logReplayFinish.release();
|
||||
|
||||
this.clearCore();
|
||||
|
||||
|
|
|
@ -398,25 +398,21 @@ public class TestDocBasedVersionConstraints extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
private Callable<Object> delayedAdd(final String... fields) {
|
||||
return Executors.callable(new Runnable() {
|
||||
public void run() {
|
||||
// log.info("ADDING DOC: " + adoc(fields));
|
||||
assertU(adoc(fields));
|
||||
}
|
||||
});
|
||||
return Executors.callable(() -> {
|
||||
// log.info("ADDING DOC: " + adoc(fields));
|
||||
assertU(adoc(fields));
|
||||
});
|
||||
}
|
||||
private Callable<Object> delayedDelete(final String id, final String externalVersion) {
|
||||
return Executors.callable(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
// Why does this throw "Exception" ???
|
||||
// log.info("DELETING DOC: " + id + " v="+externalVersion);
|
||||
deleteAndGetVersion(id, params("del_version", externalVersion));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return Executors.callable(() -> {
|
||||
try {
|
||||
// Why does this throw "Exception" ???
|
||||
// log.info("DELETING DOC: " + id + " v="+externalVersion);
|
||||
deleteAndGetVersion(id, params("del_version", externalVersion));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -656,14 +656,11 @@ public class LBHttpSolrClient extends SolrClient {
|
|||
}
|
||||
|
||||
private static Runnable getAliveCheckRunner(final WeakReference<LBHttpSolrClient> lbRef) {
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LBHttpSolrClient lb = lbRef.get();
|
||||
if (lb != null && lb.zombieServers != null) {
|
||||
for (ServerWrapper zombieServer : lb.zombieServers.values()) {
|
||||
lb.checkAZombieServer(zombieServer);
|
||||
}
|
||||
return () -> {
|
||||
LBHttpSolrClient lb = lbRef.get();
|
||||
if (lb != null && lb.zombieServers != null) {
|
||||
for (ServerWrapper zombieServer : lb.zombieServers.values()) {
|
||||
lb.checkAZombieServer(zombieServer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -263,12 +263,7 @@ public class SolrZkClient implements Closeable {
|
|||
@Override
|
||||
public void process(final WatchedEvent event) {
|
||||
log.debug("Submitting job to respond to event " + event);
|
||||
zkCallbackExecutor.submit(new Runnable () {
|
||||
@Override
|
||||
public void run () {
|
||||
watcher.process(event);
|
||||
}
|
||||
});
|
||||
zkCallbackExecutor.submit(() -> watcher.process(event));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -338,15 +338,12 @@ public class ZkStateReader implements Closeable {
|
|||
updateAliases();
|
||||
|
||||
if (securityNodeListener != null) {
|
||||
addSecuritynodeWatcher(new Callable<Pair<byte[], Stat>>() {
|
||||
@Override
|
||||
public void call(Pair<byte[], Stat> pair) {
|
||||
ConfigData cd = new ConfigData();
|
||||
cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
|
||||
cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
|
||||
securityData = cd;
|
||||
securityNodeListener.run();
|
||||
}
|
||||
addSecuritynodeWatcher(pair -> {
|
||||
ConfigData cd = new ConfigData();
|
||||
cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
|
||||
cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
|
||||
securityData = cd;
|
||||
securityNodeListener.run();
|
||||
});
|
||||
securityData = getSecurityProps(true);
|
||||
}
|
||||
|
|
|
@ -211,42 +211,39 @@ public class ExecutorUtil {
|
|||
providersCopy.get(i).store(reference);
|
||||
}
|
||||
}
|
||||
super.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isServerPool.set(Boolean.TRUE);
|
||||
if (ctx != null) {
|
||||
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).set(ctx.get(i));
|
||||
super.execute(() -> {
|
||||
isServerPool.set(Boolean.TRUE);
|
||||
if (ctx != null) {
|
||||
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).set(ctx.get(i));
|
||||
}
|
||||
Map<String, String> threadContext = MDC.getCopyOfContextMap();
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
final String oldName = currentThread.getName();
|
||||
if (submitterContext != null && !submitterContext.isEmpty()) {
|
||||
MDC.setContextMap(submitterContext);
|
||||
currentThread.setName(oldName + "-processing-" + submitterContextStr);
|
||||
} else {
|
||||
MDC.clear();
|
||||
}
|
||||
try {
|
||||
command.run();
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof OutOfMemoryError) {
|
||||
throw t;
|
||||
}
|
||||
Map<String, String> threadContext = MDC.getCopyOfContextMap();
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
final String oldName = currentThread.getName();
|
||||
if (submitterContext != null && !submitterContext.isEmpty()) {
|
||||
MDC.setContextMap(submitterContext);
|
||||
currentThread.setName(oldName + "-processing-" + submitterContextStr);
|
||||
log.error("Uncaught exception {} thrown by thread: {}", t, currentThread.getName(), submitterStackTrace);
|
||||
throw t;
|
||||
} finally {
|
||||
isServerPool.remove();
|
||||
if (threadContext != null && !threadContext.isEmpty()) {
|
||||
MDC.setContextMap(threadContext);
|
||||
} else {
|
||||
MDC.clear();
|
||||
}
|
||||
try {
|
||||
command.run();
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof OutOfMemoryError) {
|
||||
throw t;
|
||||
}
|
||||
log.error("Uncaught exception {} thrown by thread: {}", t, currentThread.getName(), submitterStackTrace);
|
||||
throw t;
|
||||
} finally {
|
||||
isServerPool.remove();
|
||||
if (threadContext != null && !threadContext.isEmpty()) {
|
||||
MDC.setContextMap(threadContext);
|
||||
} else {
|
||||
MDC.clear();
|
||||
}
|
||||
if (ctx != null) {
|
||||
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).clean(ctx.get(i));
|
||||
}
|
||||
currentThread.setName(oldName);
|
||||
if (ctx != null) {
|
||||
for (int i = 0; i < providersCopy.size(); i++) providersCopy.get(i).clean(ctx.get(i));
|
||||
}
|
||||
currentThread.setName(oldName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -201,12 +201,9 @@ public class SolrParamTest extends LuceneTestCase {
|
|||
}
|
||||
|
||||
// Malformed params: These should throw a 400
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { params.getInt( "f.bad.int" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { params.getBool( "f.bad.bool" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { params.getFloat( "f.bad.float" ); } } ) );
|
||||
assertEquals(400, getReturnCode(() -> params.getInt("f.bad.int")));
|
||||
assertEquals(400, getReturnCode(() -> params.getBool("f.bad.bool")));
|
||||
assertEquals(400, getReturnCode(() -> params.getFloat("f.bad.float")));
|
||||
|
||||
// Ask for params that arent there
|
||||
assertNull( params.get( "asagdsaga" ) );
|
||||
|
@ -243,24 +240,15 @@ public class SolrParamTest extends LuceneTestCase {
|
|||
assertEquals( pfloat , required.getFieldFloat( "fakefield", "float" ) );
|
||||
|
||||
// Required params which are missing: These should throw a 400
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.get( "aaaa" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.getInt( "f.bad.int" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.getBool( "f.bad.bool" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.getFloat( "f.bad.float" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.getInt( "aaa" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.getBool( "aaa" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { required.getFloat( "aaa" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { params.getFieldBool( "bad", "bool" ); } } ) );
|
||||
assertEquals( 400, getReturnCode( new Runnable() { @Override
|
||||
public void run() { params.getFieldInt( "bad", "int" ); } } ) );
|
||||
assertEquals(400, getReturnCode(() -> required.get("aaaa")));
|
||||
assertEquals(400, getReturnCode(() -> required.getInt("f.bad.int")));
|
||||
assertEquals(400, getReturnCode(() -> required.getBool("f.bad.bool")));
|
||||
assertEquals(400, getReturnCode(() -> required.getFloat("f.bad.float")));
|
||||
assertEquals(400, getReturnCode(() -> required.getInt("aaa")));
|
||||
assertEquals(400, getReturnCode(() -> required.getBool("aaa")));
|
||||
assertEquals(400, getReturnCode(() -> required.getFloat("aaa")));
|
||||
assertEquals(400, getReturnCode(() -> params.getFieldBool("bad", "bool")));
|
||||
assertEquals(400, getReturnCode(() -> params.getFieldInt("bad", "int")));
|
||||
|
||||
// Fields with default use their parent value:
|
||||
assertEquals(
|
||||
|
|
|
@ -442,17 +442,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
|||
final int ITERS = 1000000;
|
||||
int THREADS = 10;
|
||||
|
||||
runInThreads(THREADS, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0], 0, 0);
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
JavaBinCodec.StringBytes b = l.get(i % l.size());
|
||||
stringBytes1.reset(b.bytes, 0, b.bytes.length);
|
||||
if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
|
||||
}
|
||||
|
||||
runInThreads(THREADS, () -> {
|
||||
JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0], 0, 0);
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
JavaBinCodec.StringBytes b = l.get(i % l.size());
|
||||
stringBytes1.reset(b.bytes, 0, b.bytes.length);
|
||||
if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -461,17 +458,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
|||
System.out.println("time taken by LRUCACHE " + timer.getTime());
|
||||
timer = new RTimer();
|
||||
|
||||
runInThreads(THREADS, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String a = null;
|
||||
CharArr arr = new CharArr();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
JavaBinCodec.StringBytes sb = l.get(i % l.size());
|
||||
arr.reset();
|
||||
ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
|
||||
a = arr.toString();
|
||||
}
|
||||
runInThreads(THREADS, () -> {
|
||||
String a = null;
|
||||
CharArr arr = new CharArr();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
JavaBinCodec.StringBytes sb = l.get(i % l.size());
|
||||
arr.reset();
|
||||
ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
|
||||
a = arr.toString();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -574,14 +568,11 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
|||
if (nThreads <= 0) {
|
||||
ret += doDecode(buffers, iter, stringCache);
|
||||
} else {
|
||||
runInThreads(nThreads, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
doDecode(buffers, iter, stringCache);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
runInThreads(nThreads, () -> {
|
||||
try {
|
||||
doDecode(buffers, iter, stringCache);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1612,12 +1612,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||
final int mul = asc ? 1 : -1;
|
||||
|
||||
if (field.equals("_docid_")) {
|
||||
return new Comparator<Doc>() {
|
||||
@Override
|
||||
public int compare(Doc o1, Doc o2) {
|
||||
return (o1.order - o2.order) * mul;
|
||||
}
|
||||
};
|
||||
return (o1, o2) -> (o1.order - o2.order) * mul;
|
||||
}
|
||||
|
||||
if (field.equals("score")) {
|
||||
|
@ -1669,16 +1664,13 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public static Comparator<Doc> createComparator(final List<Comparator<Doc>> comparators) {
|
||||
return new Comparator<Doc>() {
|
||||
@Override
|
||||
public int compare(Doc o1, Doc o2) {
|
||||
int c = 0;
|
||||
for (Comparator<Doc> comparator : comparators) {
|
||||
c = comparator.compare(o1, o2);
|
||||
if (c!=0) return c;
|
||||
}
|
||||
return o1.order - o2.order;
|
||||
return (o1, o2) -> {
|
||||
int c = 0;
|
||||
for (Comparator<Doc> comparator : comparators) {
|
||||
c = comparator.compare(o1, o2);
|
||||
if (c!=0) return c;
|
||||
}
|
||||
return o1.order - o2.order;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue