Search in sources :

Example 31 with RTimer

use of org.apache.solr.util.RTimer in project lucene-solr by apache.

the class BasicDistributedZkTest method waitForDocCount.

// Insure that total docs found is the expected number.
private void waitForDocCount(long expectedNumFound, long waitMillis, String failureMessage) throws Exception {
    RTimer timer = new RTimer();
    long timeout = (long) timer.getTime() + waitMillis;
    ClusterState clusterState = getCommonCloudSolrClient().getZkStateReader().getClusterState();
    DocCollection dColl = clusterState.getCollection(DEFAULT_COLLECTION);
    // Could use this for 0 hits too!
    long docTotal = -1;
    while (docTotal != expectedNumFound && timeout > (long) timer.getTime()) {
        docTotal = checkSlicesSameCounts(dColl);
        if (docTotal != expectedNumFound) {
            Thread.sleep(100);
        }
    }
    // We could fail here if we broke out of the above because we exceeded the time allowed.
    assertEquals(failureMessage, expectedNumFound, docTotal);
    // This should be redundant, but it caught a test error after all.
    for (SolrClient client : clients) {
        assertEquals(failureMessage, expectedNumFound, client.query(new SolrQuery("*:*")).getResults().getNumFound());
    }
}
Also used : ClusterState(org.apache.solr.common.cloud.ClusterState) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) SolrClient(org.apache.solr.client.solrj.SolrClient) DocCollection(org.apache.solr.common.cloud.DocCollection) RTimer(org.apache.solr.util.RTimer) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Aggregations

RTimer (org.apache.solr.util.RTimer)31 SolrException (org.apache.solr.common.SolrException)9 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 Map (java.util.Map)4 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)4 List (java.util.List)3 Random (java.util.Random)3 SolrServerException (org.apache.solr.client.solrj.SolrServerException)3 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)3 ClusterState (org.apache.solr.common.cloud.ClusterState)3 Replica (org.apache.solr.common.cloud.Replica)3 Slice (org.apache.solr.common.cloud.Slice)3 IdentityHashMap (java.util.IdentityHashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 NoHttpResponseException (org.apache.http.NoHttpResponseException)2 SolrInputDocument (org.apache.solr.common.SolrInputDocument)2