You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by dr...@apache.org on 2015/08/19 01:18:30 UTC
[14/31] curator git commit: wip
wip
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5030c198
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5030c198
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5030c198
Branch: refs/heads/CURATOR-3.0
Commit: 5030c198456150a82bf2a2a2e5aea75b65b2efc8
Parents: ff8eb4b
Author: randgalt <ra...@apache.org>
Authored: Tue May 12 08:53:24 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Tue May 12 08:53:24 2015 -0500
----------------------------------------------------------------------
.../curator/framework/imps/WatcherRemovalManager.java | 5 ++---
.../apache/curator/framework/recipes/cache/NodeCache.java | 6 ++++--
.../apache/curator/framework/recipes/cache/TreeCache.java | 6 ++++--
.../curator/framework/recipes/cache/BaseTestTreeCache.java | 3 ++-
.../curator/framework/recipes/cache/TestNodeCache.java | 9 +++++----
5 files changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/5030c198/curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java
index 5a705a4..fe5d4d6 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Set;
-class WatcherRemovalManager
+public class WatcherRemovalManager
{
private final Logger log = LoggerFactory.getLogger(getClass());
private final CuratorFrameworkImpl client;
@@ -73,8 +73,7 @@ class WatcherRemovalManager
}
catch ( Exception e )
{
- String message = "Could not remove watcher for path: " + entry.path;
- log.error(message);
+ log.error("Could not remove watcher for path: " + entry.path);
}
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/5030c198/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
index fa0df51..4d87732 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
@@ -23,6 +23,7 @@ import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import org.apache.curator.framework.CuratorFramework;
+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.api.CuratorWatcher;
@@ -54,7 +55,7 @@ import org.apache.curator.utils.PathUtils;
public class NodeCache implements Closeable
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private final CuratorFramework client;
+ private final WatcherRemoveCuratorFramework client;
private final String path;
private final boolean dataIsCompressed;
private final EnsurePath ensurePath;
@@ -129,7 +130,7 @@ public class NodeCache implements Closeable
*/
public NodeCache(CuratorFramework client, String path, boolean dataIsCompressed)
{
- this.client = client;
+ this.client = client.newWatcherRemoveCuratorFramework();
this.path = PathUtils.validatePath(path);
this.dataIsCompressed = dataIsCompressed;
ensurePath = client.newNamespaceAwareEnsurePath(path).excludingLast();
@@ -172,6 +173,7 @@ public class NodeCache implements Closeable
{
if ( state.compareAndSet(State.STARTED, State.CLOSED) )
{
+ client.removeWatchers();
listeners.clear();
}
client.getConnectionStateListenable().removeListener(connectionStateListener);
http://git-wip-us.apache.org/repos/asf/curator/blob/5030c198/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index fbe51df..c3958aa 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -25,6 +25,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.curator.framework.CuratorFramework;
+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.api.UnhandledErrorListener;
@@ -465,7 +466,7 @@ public class TreeCache implements Closeable
private final AtomicBoolean isInitialized = new AtomicBoolean(false);
private final TreeNode root;
- private final CuratorFramework client;
+ private final WatcherRemoveCuratorFramework client;
private final CloseableExecutorService executorService;
private final boolean cacheData;
private final boolean dataIsCompressed;
@@ -513,7 +514,7 @@ public class TreeCache implements Closeable
TreeCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, int maxDepth, final CloseableExecutorService executorService)
{
this.root = new TreeNode(validatePath(path), null);
- this.client = client;
+ this.client = client.newWatcherRemoveCuratorFramework();
this.cacheData = cacheData;
this.dataIsCompressed = dataIsCompressed;
this.maxDepth = maxDepth;
@@ -545,6 +546,7 @@ public class TreeCache implements Closeable
{
if ( treeState.compareAndSet(TreeState.STARTED, TreeState.CLOSED) )
{
+ client.removeWatchers();
client.getConnectionStateListenable().removeListener(connectionStateListener);
listeners.clear();
executorService.close();
http://git-wip-us.apache.org/repos/asf/curator/blob/5030c198/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
index ab37785..f32c9b2 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
@@ -22,6 +22,7 @@ package org.apache.curator.framework.recipes.cache;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.Timing;
@@ -123,7 +124,7 @@ public class BaseTestTreeCache extends BaseClassForTests
finally
{
CloseableUtils.closeQuietly(cache);
- CloseableUtils.closeQuietly(client);
+ TestCleanState.closeAndTestClean(client);
}
}
finally
http://git-wip-us.apache.org/repos/asf/curator/blob/5030c198/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
index 27af6ac..d6d495a 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.framework.recipes.cache;
+import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@@ -98,7 +99,7 @@ public class TestNodeCache extends BaseClassForTests
finally
{
CloseableUtils.closeQuietly(cache);
- CloseableUtils.closeQuietly(client);
+ TestCleanState.closeAndTestClean(client);
}
}
@@ -161,7 +162,7 @@ public class TestNodeCache extends BaseClassForTests
finally
{
CloseableUtils.closeQuietly(cache);
- CloseableUtils.closeQuietly(client);
+ TestCleanState.closeAndTestClean(client);
}
}
@@ -204,7 +205,7 @@ public class TestNodeCache extends BaseClassForTests
finally
{
CloseableUtils.closeQuietly(cache);
- CloseableUtils.closeQuietly(client);
+ TestCleanState.closeAndTestClean(client);
}
}
@@ -252,7 +253,7 @@ public class TestNodeCache extends BaseClassForTests
finally
{
CloseableUtils.closeQuietly(cache);
- CloseableUtils.closeQuietly(client);
+ TestCleanState.closeAndTestClean(client);
}
}
}