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 2015/06/25 01:06:51 UTC

curator git commit: Added createContainers() to the main API as it's used too often. Applied it where needed (fixing some issues created when removing ensurePath)

Repository: curator
Updated Branches:
  refs/heads/CURATOR-222 8226f0cc3 -> 47da6211f


Added createContainers() to the main API as it's used too often. Applied it where needed (fixing some issues created when removing ensurePath)


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

Branch: refs/heads/CURATOR-222
Commit: 47da6211fcd82fcb8454f3464a94bf7f1e88d00e
Parents: 8226f0c
Author: randgalt <ra...@apache.org>
Authored: Wed Jun 24 17:23:07 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Wed Jun 24 17:23:07 2015 -0500

----------------------------------------------------------------------
 .../org/apache/curator/framework/CuratorFramework.java  | 12 +++++++++++-
 .../curator/framework/imps/CuratorFrameworkImpl.java    |  7 +++++++
 .../apache/curator/framework/imps/NamespaceFacade.java  |  6 ++++++
 .../framework/recipes/cache/PathChildrenCache.java      |  2 +-
 .../curator/framework/recipes/cache/TreeCache.java      |  2 +-
 .../curator/framework/recipes/queue/QueueSharder.java   |  2 +-
 .../framework/recipes/queue/SimpleDistributedQueue.java |  2 +-
 .../curator/framework/recipes/cache/TestTreeCache.java  |  2 +-
 8 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
index de9bcc5..b9d67b9 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
@@ -139,6 +139,15 @@ public interface CuratorFramework extends Closeable
     public void sync(String path, Object backgroundContextObject);
 
     /**
+     * Create all nodes in the specified path as containers if they don't
+     * already exist
+     *
+     * @param path path to create
+     * @throws Exception errors
+     */
+    public void createContainers(String path) throws Exception;
+
+    /**
      * Start a sync builder. Note: sync is ALWAYS in the background even
      * if you don't use one of the background() methods
      *
@@ -205,7 +214,8 @@ public interface CuratorFramework extends Closeable
      *
      * @param path path to ensure
      * @return new EnsurePath instance
-     * @deprecated Since 2.9.0 - prefer {@link CreateBuilder#creatingParentContainersIfNeeded()} or {@link ExistsBuilder#creatingParentContainersIfNeeded()}
+     * @deprecated Since 2.9.0 - prefer {@link CreateBuilder#creatingParentContainersIfNeeded()}, {@link ExistsBuilder#creatingParentContainersIfNeeded()}
+     * or {@link CuratorFramework#createContainers(String)}
      */
     @Deprecated
     public EnsurePath newNamespaceAwareEnsurePath(String path);

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 30a6a55..38ce166 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -40,6 +40,7 @@ import org.apache.curator.framework.state.ConnectionStateManager;
 import org.apache.curator.utils.DebugUtils;
 import org.apache.curator.utils.EnsurePath;
 import org.apache.curator.utils.ThreadUtils;
+import org.apache.curator.utils.ZKPaths;
 import org.apache.curator.utils.ZookeeperFactory;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
@@ -187,6 +188,12 @@ public class CuratorFrameworkImpl implements CuratorFramework
     }
 
     @Override
+    public void createContainers(String path) throws Exception
+    {
+        checkExists().creatingParentContainersIfNeeded().forPath(ZKPaths.makePath(path, "foo"));
+    }
+
+    @Override
     public void clearWatcherReferences(Watcher watcher)
     {
         NamespaceWatcher namespaceWatcher = namespaceWatcherMap.remove(watcher);

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
index 95bf132..60ef647 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
@@ -43,6 +43,12 @@ class NamespaceFacade extends CuratorFrameworkImpl
     }
 
     @Override
+    public void createContainers(String path) throws Exception
+    {
+        client.createContainers(path);
+    }
+
+    @Override
     public CuratorFramework nonNamespaceView()
     {
         return usingNamespace(null);

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/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 2010008..5a7b424 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
@@ -613,7 +613,7 @@ public class PathChildrenCache implements Closeable
 
     private void ensurePath() throws Exception
     {
-        client.checkExists().creatingParentContainersIfNeeded().forPath(path);
+        client.createContainers(path);
     }
 
     private void handleStateChange(ConnectionState newState)

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/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 16da736..71efd28 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
@@ -548,7 +548,7 @@ public class TreeCache implements Closeable
         Preconditions.checkState(treeState.compareAndSet(TreeState.LATENT, TreeState.STARTED), "already started");
         if ( createParentNodes )
         {
-            client.checkExists().creatingParentContainersIfNeeded().forPath(root.path);
+            client.createContainers(root.path);
         }
         client.getConnectionStateListenable().addListener(connectionStateListener);
         if ( client.getZookeeperClient().isConnected() )

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
index c54e513..455794c 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
@@ -111,7 +111,7 @@ public class QueueSharder<U, T extends QueueBase<U>> implements Closeable
     {
         Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");
 
-        client.checkExists().creatingParentContainersIfNeeded().forPath(ZKPaths.makePath(queuePath, "foo"));
+        client.createContainers(queuePath);
 
         getInitialQueues();
         leaderLatch.start();

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/SimpleDistributedQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/SimpleDistributedQueue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/SimpleDistributedQueue.java
index dd07d1c..9650ffb 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/SimpleDistributedQueue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/SimpleDistributedQueue.java
@@ -217,7 +217,7 @@ public class SimpleDistributedQueue
 
     private void ensurePath() throws Exception
     {
-        client.checkExists().creatingParentContainersIfNeeded().forPath(path);
+        client.createContainers(path);
     }
 
     private byte[] internalElement(boolean removeIt, Watcher watcher) throws Exception

http://git-wip-us.apache.org/repos/asf/curator/blob/47da6211/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
index e98c21f..e1c61d0 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
@@ -65,7 +65,7 @@ public class TestTreeCache extends BaseTestTreeCache
 
         cache = TreeCache.newBuilder(client, "/one/two/three").setCreateParentNodes(true).build();
         cache.start();
-        Assert.assertNotNull(client.checkExists().forPath("/one/two"));
+        Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
     }
 
     @Test