Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89BC3183E6 for ; Mon, 17 Aug 2015 17:02:27 +0000 (UTC) Received: (qmail 80366 invoked by uid 500); 17 Aug 2015 17:02:09 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 80295 invoked by uid 500); 17 Aug 2015 17:02:09 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 79533 invoked by uid 99); 17 Aug 2015 17:02:09 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2015 17:02:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 792F0E0329; Mon, 17 Aug 2015 17:02:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dragonsinth@apache.org To: commits@curator.apache.org Date: Mon, 17 Aug 2015 17:02:31 -0000 Message-Id: <3f0daf6ed0334ddb8558e2e3b0181265@git.apache.org> In-Reply-To: <7ac50fe071104b4493121735a87f2dc8@git.apache.org> References: <7ac50fe071104b4493121735a87f2dc8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/41] 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) 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-3.0 Commit: 47da6211fcd82fcb8454f3464a94bf7f1e88d00e Parents: 8226f0c Author: randgalt Authored: Wed Jun 24 17:23:07 2015 -0500 Committer: randgalt 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> 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