kaisun2000 commented on a change in pull request #1035:
URL: https://github.com/apache/helix/pull/1035#discussion_r434996500



##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -1054,15 +1082,47 @@ public Stat getStat(final String path) {
   }
 
   private Stat getStat(final String path, final boolean watch) {
+    return getStat(path, watch, false);
+  }
+
+  /*
+   * Install watch if there is such node and return the stat
+   *
+   * If useGetData false, use exist(). @param watch would determine if adding 
watch
+   * to ZooKeeper server or not.
+   * Note, if @param path does not exist in ZooKeeper server, watch would 
still be installed
+   * if @param watch is true.
+   *
+   * If useGetData true, use getData() to add watch. ignore @param watch in 
this case.
+   * Note, if @param path does not exist in ZooKeeper server, no watch would 
be added.
+   */
+  private Stat getStat(final String path, final boolean watch, final boolean 
useGetData) {
     long startT = System.currentTimeMillis();
+    Stat stat = null;
     try {
-      Stat stat = retryUntilConnected(
-          () -> ((ZkConnection) getConnection()).getZookeeper().exists(path, 
watch));
+      if (!useGetData) {
+        stat = retryUntilConnected(
+            () -> ((ZkConnection) getConnection()).getZookeeper().exists(path, 
watch));
+      } else {
+        stat = new Stat();
+        try {
+          LOG.debug("getstat() invoked with useGetData() with path: " + path);
+          Stat finalStat = stat;
+          retryUntilConnected(() -> ((ZkConnection) 
getConnection()).getZookeeper().getData(path, true, finalStat));
+        } catch (ZkNoNodeException e) {
+          LOG.debug("getstat() invoked path: " + path + " null" + " 
useGetData:" + useGetData);

Review comment:
       Good point. Changed all that I added.




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to