You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2018/12/09 07:28:04 UTC

[1/4] curator git commit: CURATOR-491

Repository: curator
Updated Branches:
  refs/heads/master d7774c428 -> 2adccc549


CURATOR-491

CURATOR-332 fixed part of this, but there's another background handler that has the same problem.

The background handler in {{refresh()}} correctly checks if the instance has been closed before processing as well as clearing watchers that might have been set in the interim. This same treatment needs to be added to the background handler in {{getDataAndStat()}}.


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b0cd9190
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b0cd9190
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b0cd9190

Branch: refs/heads/master
Commit: b0cd91908973ff0b2ec3f5b5d117f51a514d9cd0
Parents: 6a9c6ab
Author: randgalt <ra...@apache.org>
Authored: Sat Dec 8 19:21:07 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sat Dec 8 19:21:07 2018 -0500

----------------------------------------------------------------------
 .../recipes/cache/PathChildrenCache.java        | 31 ++++++++++++++++----
 1 file changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/b0cd9190/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
index f8c4e93..17044e5 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
@@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.WatcherRemoveCuratorFramework;
 import org.apache.curator.framework.EnsureContainers;
+import org.apache.curator.framework.WatcherRemoveCuratorFramework;
 import org.apache.curator.framework.api.BackgroundCallback;
 import org.apache.curator.framework.api.CuratorEvent;
 import org.apache.curator.framework.listen.ListenerContainer;
@@ -44,13 +44,16 @@ import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.io.Closeable;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.*;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Exchanger;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -94,6 +97,7 @@ public class PathChildrenCache implements Closeable
         @Override
         public void process(WatchedEvent event)
         {
+            System.err.println("child: " + event);
             offerOperation(new RefreshOperation(PathChildrenCache.this, RefreshMode.STANDARD));
         }
     };
@@ -103,6 +107,7 @@ public class PathChildrenCache implements Closeable
         @Override
         public void process(WatchedEvent event)
         {
+            System.err.println("data: " + event);
             try
             {
                 if ( event.getType() == Event.EventType.NodeDeleted )
@@ -373,6 +378,7 @@ public class PathChildrenCache implements Closeable
         {
             client.getConnectionStateListenable().removeListener(connectionStateListener);
             listeners.clear();
+
             executorService.close();
             client.removeWatchers();
 
@@ -492,9 +498,8 @@ public class PathChildrenCache implements Closeable
             @Override
             public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
             {
-                if (PathChildrenCache.this.state.get().equals(State.CLOSED)) {
-                    // This ship is closed, don't handle the callback
-                    PathChildrenCache.this.client.removeWatchers();
+                if ( reRemoveWatchersOnBackgroundClosed() )
+                {
                     return;
                 }
                 if ( event.getResultCode() == KeeperException.Code.OK.intValue() )
@@ -552,6 +557,10 @@ public class PathChildrenCache implements Closeable
             @Override
             public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
             {
+                if ( reRemoveWatchersOnBackgroundClosed() )
+                {
+                    return;
+                }
                 applyNewData(fullPath, event.getResultCode(), event.getStat(), cacheData ? event.getData() : null);
             }
         };
@@ -606,6 +615,16 @@ public class PathChildrenCache implements Closeable
         }
     }
 
+    private boolean reRemoveWatchersOnBackgroundClosed()
+    {
+        if ( state.get().equals(State.CLOSED))
+        {
+        //    client.removeWatchers();
+            return true;
+        }
+        return false;
+    }
+
     private void internalRebuildNode(String fullPath) throws Exception
     {
         if ( cacheData )


[4/4] curator git commit: Merge branch 'CURATOR-491'

Posted by ra...@apache.org.
Merge branch 'CURATOR-491'


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/2adccc54
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/2adccc54
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/2adccc54

Branch: refs/heads/master
Commit: 2adccc54976ce028d8cfe4bf1e7ac6c404829e78
Parents: d7774c4 49d08cc
Author: randgalt <ra...@apache.org>
Authored: Sun Dec 9 02:27:54 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Dec 9 02:27:54 2018 -0500

----------------------------------------------------------------------
 .../recipes/cache/PathChildrenCache.java        | 29 ++++++++++++++++----
 1 file changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[2/4] curator git commit: removed debug prints

Posted by ra...@apache.org.
removed debug prints


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/aea4086f
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/aea4086f
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/aea4086f

Branch: refs/heads/master
Commit: aea4086f802a70670a9714a2325a1b6451ddb20e
Parents: b0cd919
Author: randgalt <ra...@apache.org>
Authored: Sat Dec 8 19:22:42 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sat Dec 8 19:22:42 2018 -0500

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/cache/PathChildrenCache.java  | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/aea4086f/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
index 17044e5..2ff8a96 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
@@ -97,7 +97,6 @@ public class PathChildrenCache implements Closeable
         @Override
         public void process(WatchedEvent event)
         {
-            System.err.println("child: " + event);
             offerOperation(new RefreshOperation(PathChildrenCache.this, RefreshMode.STANDARD));
         }
     };
@@ -107,7 +106,6 @@ public class PathChildrenCache implements Closeable
         @Override
         public void process(WatchedEvent event)
         {
-            System.err.println("data: " + event);
             try
             {
                 if ( event.getType() == Event.EventType.NodeDeleted )


[3/4] curator git commit: left code commented out

Posted by ra...@apache.org.
left code commented out


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/49d08ccc
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/49d08ccc
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/49d08ccc

Branch: refs/heads/master
Commit: 49d08ccca27113b24bceb74ed372fd7b5910994b
Parents: aea4086
Author: randgalt <ra...@apache.org>
Authored: Sat Dec 8 19:24:24 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sat Dec 8 19:24:24 2018 -0500

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/cache/PathChildrenCache.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/49d08ccc/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
index 2ff8a96..bdc73cc 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
@@ -617,7 +617,7 @@ public class PathChildrenCache implements Closeable
     {
         if ( state.get().equals(State.CLOSED))
         {
-        //    client.removeWatchers();
+            client.removeWatchers();
             return true;
         }
         return false;