dragonsinth commented on a change in pull request #1446:
URL: https://github.com/apache/lucene-solr/pull/1446#discussion_r416945913



##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
##########
@@ -843,6 +847,31 @@ public void downloadFromZK(String zkPath, Path dir) throws 
IOException {
     ZkMaintenanceUtils.downloadFromZK(this, zkPath, dir);
   }
 
+  /**
+   * Ensures we can subsequently read the most up-to-date state of the 
provided {@code path} and all data below
+   * it, after this method completes.
+   * This should not be called a lot; there may be some delay.  Consider 
alternative approaches It's often better to try to devise a way to
+   * "watch" for state changed instead of calling this.
+   */
+  public void sync(String path) {
+    // zookeeper.sync is asynchronous; we need to wait till it's done
+    CompletableFuture<Integer> future = new CompletableFuture<>();
+    keeper.sync(path, (rc, path1, ctx) -> future.complete(rc), null);
+    try {
+      Integer status = future.get(zkClientTimeout, TimeUnit.MILLISECONDS);

Review comment:
       Dumb question from something who hasn't dug into ZK client code in Java 
in ages, but if you're waiting on the answer anyway, why use a future and then 
wait it instead of just calling a synchronous method to begin with?  Or is more 
like, "I'm waiting on potentially lots and lots of answers, I just need it to 
be up to date with any previous operations"?




----------------------------------------------------------------
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



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

Reply via email to