You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/01/19 15:24:52 UTC

[GitHub] [helix] dasahcc commented on a change in pull request #688: Fix the watcher leakage issue

dasahcc commented on a change in pull request #688: Fix the watcher leakage issue
URL: https://github.com/apache/helix/pull/688#discussion_r368301621
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
 ##########
 @@ -145,32 +145,28 @@ public int hashCode() {
 
   private class ZkPathStatRecord {
     private final String _path;
-    private Stat _stat = null;
-    private boolean _checked = false;
+    private AtomicBoolean _isChecked = new AtomicBoolean(false);
 
-    public ZkPathStatRecord(String path) {
+    ZkPathStatRecord(String path) {
       _path = path;
     }
 
-    public boolean pathExists() {
-      return _stat != null;
-    }
-
-    public boolean pathChecked() {
-      return _checked;
+    boolean isPathChecked() {
+      return _isChecked.get();
     }
 
     /*
      * Note this method is not thread safe.
      */
-    public void recordPathStat(Stat stat, OptionalLong notificationTime) {
-      _checked = true;
-      _stat = stat;
-
-      if (_monitor != null && stat != null && notificationTime.isPresent()) {
+    void recordPathStat(Stat stat, long notificationTime) {
+      if (isPathChecked()) {
+        return;
+      }
+      _isChecked.set(true);
+      if (_monitor != null && stat != null) {
         long updateTime = Math.max(stat.getCtime(), stat.getMtime());
-        if (notificationTime.getAsLong() > updateTime) {
-          _monitor.recordDataPropagationLatency(_path, notificationTime.getAsLong() - updateTime);
+        if (notificationTime > updateTime) {
+          _monitor.recordDataPropagationLatency(_path, notificationTime - updateTime);
 
 Review comment:
   I did not see the value of changing this. If you feel this is necessary, please make it for separate PR as it does impact logic and purely code refactoring.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org