use of org.apache.solr.util.TimeOut in project lucene-solr by apache.
the class DistribDocExpirationUpdateProcessorTest method waitForNoResults.
/**
* Executes a query over and over against the cloudClient every 5 seconds
* until the numFound is 0 or the maxTimeLimitSeconds is exceeded.
* Query is guaranteed to be executed at least once.
*/
private void waitForNoResults(int maxTimeLimitSeconds, SolrParams params) throws SolrServerException, InterruptedException, IOException {
final TimeOut timeout = new TimeOut(maxTimeLimitSeconds, TimeUnit.SECONDS);
long numFound = cluster.getSolrClient().query(COLLECTION, params).getResults().getNumFound();
while (0L < numFound && !timeout.hasTimedOut()) {
Thread.sleep(Math.max(1, Math.min(5000, timeout.timeLeft(TimeUnit.MILLISECONDS))));
numFound = cluster.getSolrClient().query(COLLECTION, params).getResults().getNumFound();
}
assertEquals("Give up waiting for no results: " + params, 0L, numFound);
}
use of org.apache.solr.util.TimeOut in project lucene-solr by apache.
the class CollectionsAPIDistributedZkTest method waitForReloads.
private boolean waitForReloads(String collectionName, Map<String, Long> urlToTimeBefore) throws SolrServerException, IOException {
TimeOut timeout = new TimeOut(45, TimeUnit.SECONDS);
boolean allTimesAreCorrect = false;
while (!timeout.hasTimedOut()) {
Map<String, Long> urlToTimeAfter = new HashMap<>();
collectStartTimes(collectionName, urlToTimeAfter);
boolean retry = false;
Set<Entry<String, Long>> entries = urlToTimeBefore.entrySet();
for (Entry<String, Long> entry : entries) {
Long beforeTime = entry.getValue();
Long afterTime = urlToTimeAfter.get(entry.getKey());
assertNotNull(afterTime);
if (afterTime <= beforeTime) {
retry = true;
break;
}
}
if (!retry) {
allTimesAreCorrect = true;
break;
}
}
return allTimesAreCorrect;
}
use of org.apache.solr.util.TimeOut in project lucene-solr by apache.
the class UnloadDistributedZkTest method checkCoreNamePresenceAndSliceCount.
private void checkCoreNamePresenceAndSliceCount(String collectionName, String coreName, boolean shouldBePresent, int expectedSliceCount) throws Exception {
final TimeOut timeout = new TimeOut(45, TimeUnit.SECONDS);
// null meaning "don't know"
Boolean isPresent = null;
while (null == isPresent || shouldBePresent != isPresent.booleanValue()) {
final Collection<Slice> slices = getCommonCloudSolrClient().getZkStateReader().getClusterState().getSlices(collectionName);
if (timeout.hasTimedOut()) {
printLayout();
fail("checkCoreNamePresenceAndSliceCount failed:" + " collection=" + collectionName + " CoreName=" + coreName + " shouldBePresent=" + shouldBePresent + " isPresent=" + isPresent + " expectedSliceCount=" + expectedSliceCount + " actualSliceCount=" + slices.size());
}
if (expectedSliceCount == (slices == null ? 0 : slices.size())) {
isPresent = false;
if (slices != null) {
for (Slice slice : slices) {
for (Replica replica : slice.getReplicas()) {
if (coreName.equals(replica.get("core"))) {
isPresent = true;
}
}
}
}
}
Thread.sleep(1000);
}
}
Aggregations