tflobbe commented on a change in pull request #1297: SOLR-14253 Replace various 
sleep calls with ZK waits
URL: https://github.com/apache/lucene-solr/pull/1297#discussion_r385436558
 
 

 ##########
 File path: 
solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java
 ##########
 @@ -471,29 +471,21 @@ void checkResults(String label, NamedList<Object> 
results, boolean failureIsFata
   private void migrateStateFormat(ClusterState state, ZkNodeProps message, 
NamedList results) throws Exception {
     final String collectionName = message.getStr(COLLECTION_PROP);
 
-    boolean firstLoop = true;
-    // wait for a while until the state format changes
-    TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS, timeSource);
-    while (! timeout.hasTimedOut()) {
-      DocCollection collection = 
zkStateReader.getClusterState().getCollection(collectionName);
-      if (collection == null) {
-        throw new SolrException(ErrorCode.BAD_REQUEST, "Collection: " + 
collectionName + " not found");
-      }
-      if (collection.getStateFormat() == 2) {
-        // Done.
-        results.add("success", new SimpleOrderedMap<>());
-        return;
-      }
+    ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, 
MIGRATESTATEFORMAT.toLower(), COLLECTION_PROP, collectionName);
+    overseer.offerStateUpdate(Utils.toJSON(m));
 
-      if (firstLoop) {
-        // Actually queue the migration command.
-        firstLoop = false;
-        ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, 
MIGRATESTATEFORMAT.toLower(), COLLECTION_PROP, collectionName);
-        overseer.offerStateUpdate(Utils.toJSON(m));
-      }
-      timeout.sleep(100);
+    try {
+      zkStateReader.waitForState(collectionName, 30, TimeUnit.SECONDS, c -> {
 
 Review comment:
   same comment/questions as with the other methods

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to