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 CEE12182D3 for ; Wed, 1 Jul 2015 23:01:18 +0000 (UTC) Received: (qmail 52794 invoked by uid 500); 1 Jul 2015 23:01:18 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 52706 invoked by uid 500); 1 Jul 2015 23:01:18 -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 52543 invoked by uid 99); 1 Jul 2015 23:01:18 -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; Wed, 01 Jul 2015 23:01:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 64A72E05DD; Wed, 1 Jul 2015 23:01:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: randgalt@apache.org To: commits@curator.apache.org Date: Wed, 01 Jul 2015 23:01:24 -0000 Message-Id: <490a48aa23394d7693e082045f15af51@git.apache.org> In-Reply-To: <670a3ea55ea342d2ad4795731839be3f@git.apache.org> References: <670a3ea55ea342d2ad4795731839be3f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/20] curator git commit: Got rid of EnsurePathContainers. It's not needed and confusing Got rid of EnsurePathContainers. It's not needed and confusing Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b3cf69d0 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b3cf69d0 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b3cf69d0 Branch: refs/heads/master Commit: b3cf69d0a683393556bff6ccefca33b9c8325b93 Parents: 12baea3 Author: randgalt Authored: Tue May 19 16:08:53 2015 -0700 Committer: randgalt Committed: Tue May 19 16:08:53 2015 -0700 ---------------------------------------------------------------------- .../org/apache/curator/utils/EnsurePath.java | 11 ---- .../curator/utils/EnsurePathContainers.java | 49 ---------------- .../java/org/apache/curator/utils/ZKPaths.java | 2 +- .../curator/framework/CuratorFramework.java | 10 ---- .../framework/CuratorFrameworkFactory.java | 3 +- .../framework/imps/CuratorFrameworkImpl.java | 18 ------ .../curator/framework/imps/NamespaceFacade.java | 11 +--- .../curator/framework/imps/NamespaceImpl.java | 8 +-- .../curator/framework/imps/TestFramework.java | 59 -------------------- .../recipes/atomic/DistributedAtomicValue.java | 10 +--- .../framework/recipes/cache/NodeCache.java | 6 +- .../recipes/cache/PathChildrenCache.java | 6 +- .../recipes/queue/SimpleDistributedQueue.java | 11 +--- 13 files changed, 15 insertions(+), 189 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-client/src/main/java/org/apache/curator/utils/EnsurePath.java ---------------------------------------------------------------------- diff --git a/curator-client/src/main/java/org/apache/curator/utils/EnsurePath.java b/curator-client/src/main/java/org/apache/curator/utils/EnsurePath.java index 3181aca..3abb618 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/EnsurePath.java +++ b/curator-client/src/main/java/org/apache/curator/utils/EnsurePath.java @@ -110,17 +110,6 @@ public class EnsurePath return new EnsurePath(path, helper, false, aclProvider); } - /** - * Returns a view of this EnsurePath instance that does not make the last node and also makes containers. - * i.e. if the path is "/a/b/c" only "/a/b" will be ensured - * - * @return view - */ - public EnsurePathContainers excludingLastContainers() - { - return new EnsurePathContainers(path, helper, false, aclProvider); - } - protected EnsurePath(String path, AtomicReference helper, boolean makeLastNode, InternalACLProvider aclProvider) { this.path = path; http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-client/src/main/java/org/apache/curator/utils/EnsurePathContainers.java ---------------------------------------------------------------------- diff --git a/curator-client/src/main/java/org/apache/curator/utils/EnsurePathContainers.java b/curator-client/src/main/java/org/apache/curator/utils/EnsurePathContainers.java deleted file mode 100644 index 455d58d..0000000 --- a/curator-client/src/main/java/org/apache/curator/utils/EnsurePathContainers.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.utils; - -import org.apache.zookeeper.CreateMode; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Same as {@link EnsurePath} but creates parents as {@link CreateMode#CONTAINER} - */ -public class EnsurePathContainers extends EnsurePath -{ - public EnsurePathContainers(String path) - { - super(path); - } - - public EnsurePathContainers(String path, InternalACLProvider aclProvider) - { - super(path, aclProvider); - } - - EnsurePathContainers(String path, AtomicReference helper, boolean makeLastNode, InternalACLProvider aclProvider) - { - super(path, helper, makeLastNode, aclProvider); - } - - @Override - protected boolean asContainers() - { - return true; - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java ---------------------------------------------------------------------- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 13b0cba..f025fa6 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -61,7 +61,7 @@ public class ZKPaths catch ( IllegalArgumentException ignore ) { localCreateMode = CreateMode.PERSISTENT; - log.warn("The version of ZooKeeper being used doesn't support Container nodes. CreateMode.PERSISTENT will be used instead"); + log.warn("The version of ZooKeeper being used doesn't support Container nodes. CreateMode.PERSISTENT will be used instead."); } containerCreateMode = localCreateMode; } http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/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 0e09872..fe03dc6 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 @@ -24,10 +24,8 @@ import org.apache.curator.framework.api.*; import org.apache.curator.framework.api.transaction.CuratorTransaction; import org.apache.curator.framework.imps.CuratorFrameworkState; import org.apache.curator.framework.listen.Listenable; -import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.utils.EnsurePath; -import org.apache.curator.utils.EnsurePathContainers; import org.apache.zookeeper.Watcher; import java.io.Closeable; @@ -208,14 +206,6 @@ public interface CuratorFramework extends Closeable public EnsurePath newNamespaceAwareEnsurePath(String path); /** - * Allocates an ensure path containers instance that is namespace aware - * - * @param path path to ensure - * @return new EnsurePath instance - */ - public EnsurePathContainers newNamespaceAwareEnsurePathContainers(String path); - - /** * Curator can hold internal references to watchers that may inhibit garbage collection. * Call this method on watchers you are no longer interested in. * http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java index c9c9c10..dcb2ee6 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java @@ -32,7 +32,6 @@ import org.apache.curator.framework.imps.CuratorTempFrameworkImpl; import org.apache.curator.framework.imps.DefaultACLProvider; import org.apache.curator.framework.imps.GzipCompressionProvider; import org.apache.curator.utils.DefaultZookeeperFactory; -import org.apache.curator.utils.EnsurePathContainers; import org.apache.curator.utils.ZookeeperFactory; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.Watcher; @@ -333,7 +332,7 @@ public class CuratorFrameworkFactory } /** - * By default, Curator uses {@link EnsurePathContainers} and {@link CreateBuilder#creatingParentContainersIfNeeded()} + * By default, Curator uses {@link CreateBuilder#creatingParentContainersIfNeeded()} * if the ZK JAR supports {@link CreateMode#CONTAINER}. Call this method to turn off this behavior. * * @return this http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/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 8ddbfb5..30a6a55 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 @@ -39,7 +39,6 @@ import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.framework.state.ConnectionStateManager; import org.apache.curator.utils.DebugUtils; import org.apache.curator.utils.EnsurePath; -import org.apache.curator.utils.EnsurePathContainers; import org.apache.curator.utils.ThreadUtils; import org.apache.curator.utils.ZookeeperFactory; import org.apache.zookeeper.KeeperException; @@ -461,23 +460,6 @@ public class CuratorFrameworkImpl implements CuratorFramework return namespace.newNamespaceAwareEnsurePath(path); } - @Override - public EnsurePathContainers newNamespaceAwareEnsurePathContainers(String path) - { - if ( useContainerParentsIfAvailable ) - { - return namespace.newNamespaceAwareEnsurePathContainers(path); - } - return new EnsurePathContainers(path) - { - @Override - protected boolean asContainers() - { - return false; - } - }; - } - ACLProvider getAclProvider() { return aclProvider; http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/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 7807f69..95bf132 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 @@ -21,11 +21,12 @@ package org.apache.curator.framework.imps; import org.apache.curator.CuratorZookeeperClient; import org.apache.curator.RetryLoop; import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.api.*; +import org.apache.curator.framework.api.CuratorEvent; +import org.apache.curator.framework.api.CuratorListener; +import org.apache.curator.framework.api.UnhandledErrorListener; import org.apache.curator.framework.listen.Listenable; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.utils.EnsurePath; -import org.apache.curator.utils.EnsurePathContainers; import org.apache.zookeeper.ZooKeeper; class NamespaceFacade extends CuratorFrameworkImpl @@ -150,12 +151,6 @@ class NamespaceFacade extends CuratorFrameworkImpl } @Override - public EnsurePathContainers newNamespaceAwareEnsurePathContainers(String path) - { - return namespace.newNamespaceAwareEnsurePathContainers(path); - } - - @Override FailedDeleteManager getFailedDeleteManager() { return failedDeleteManager; http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java index 99f2b3b..03411a2 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java @@ -19,9 +19,8 @@ package org.apache.curator.framework.imps; import org.apache.curator.utils.EnsurePath; -import org.apache.curator.utils.EnsurePathContainers; -import org.apache.curator.utils.ZKPaths; import org.apache.curator.utils.PathUtils; +import org.apache.curator.utils.ZKPaths; class NamespaceImpl { @@ -87,9 +86,4 @@ class NamespaceImpl { return new EnsurePath(fixForNamespace(path, false), client.getAclProvider()); } - - EnsurePathContainers newNamespaceAwareEnsurePathContainers(String path) - { - return new EnsurePathContainers(fixForNamespace(path, false), client.getAclProvider()); - } } http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java index 15db5de..32eea40 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java @@ -447,65 +447,6 @@ public class TestFramework extends BaseClassForTests } @Test - public void testOverrideEnsureParentContainers() throws Exception - { - CuratorFramework client = CuratorFrameworkFactory.builder() - .connectString(server.getConnectString()) - .retryPolicy(new RetryOneTime(1)) - .dontUseContainerParents() - .build(); - try - { - client.start(); - EnsurePath ensurePath = client.newNamespaceAwareEnsurePathContainers("/one/two"); - ensurePath.ensure(client.getZookeeperClient()); - client.create().creatingParentContainersIfNeeded().forPath("/one/two/three", "foo".getBytes()); - byte[] data = client.getData().forPath("/one/two/three"); - Assert.assertEquals(data, "foo".getBytes()); - - client.delete().forPath("/one/two/three"); - new Timing().sleepABit(); - - Assert.assertNotNull(client.checkExists().forPath("/one/two")); - new Timing().sleepABit(); - Assert.assertNotNull(client.checkExists().forPath("/one")); - } - finally - { - client.close(); - } - } - - @Test - public void testEnsureParentContainers() throws Exception - { - CuratorFramework client = CuratorFrameworkFactory.builder() - .connectString(server.getConnectString()) - .retryPolicy(new RetryOneTime(1)) - .build(); - try - { - client.start(); - EnsurePath ensurePath = client.newNamespaceAwareEnsurePathContainers("/one/two"); - ensurePath.ensure(client.getZookeeperClient()); - client.create().creatingParentContainersIfNeeded().forPath("/one/two/three", "foo".getBytes()); - byte[] data = client.getData().forPath("/one/two/three"); - Assert.assertEquals(data, "foo".getBytes()); - - client.delete().forPath("/one/two/three"); - new Timing().sleepABit(); - - Assert.assertNull(client.checkExists().forPath("/one/two")); - new Timing().sleepABit(); - Assert.assertNull(client.checkExists().forPath("/one")); - } - finally - { - client.close(); - } - } - - @Test public void testCreateParentContainers() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/curator-recipes/src/main/java/org/apache/curator/framework/recipes/atomic/DistributedAtomicValue.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/atomic/DistributedAtomicValue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/atomic/DistributedAtomicValue.java index 8553364..1a11c4a 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/atomic/DistributedAtomicValue.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/atomic/DistributedAtomicValue.java @@ -22,7 +22,6 @@ import org.apache.curator.RetryLoop; import org.apache.curator.RetryPolicy; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.locks.InterProcessMutex; -import org.apache.curator.utils.EnsurePathContainers; import org.apache.curator.utils.PathUtils; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.data.Stat; @@ -43,7 +42,6 @@ public class DistributedAtomicValue private final RetryPolicy retryPolicy; private final PromotedToLock promotedToLock; private final InterProcessMutex mutex; - private final EnsurePathContainers ensurePath; /** * Creates in optimistic mode only - i.e. the promotion to a mutex is not done @@ -74,7 +72,6 @@ public class DistributedAtomicValue this.retryPolicy = retryPolicy; this.promotedToLock = promotedToLock; mutex = (promotedToLock != null) ? new InterProcessMutex(client, promotedToLock.getPath()) : null; - ensurePath = client.newNamespaceAwareEnsurePathContainers(path).excludingLastContainers(); } /** @@ -103,14 +100,13 @@ public class DistributedAtomicValue { try { - ensurePath.ensure(client.getZookeeperClient()); client.setData().forPath(path, newValue); } catch ( KeeperException.NoNodeException dummy ) { try { - client.create().forPath(path, newValue); + client.create().creatingParentContainersIfNeeded().forPath(path, newValue); } catch ( KeeperException.NodeExistsException dummy2 ) { @@ -198,10 +194,9 @@ public class DistributedAtomicValue */ public boolean initialize(byte[] value) throws Exception { - ensurePath.ensure(client.getZookeeperClient()); try { - client.create().forPath(path, value); + client.create().creatingParentContainersIfNeeded().forPath(path, value); } catch ( KeeperException.NodeExistsException ignore ) { @@ -250,7 +245,6 @@ public class DistributedAtomicValue boolean createIt = false; try { - ensurePath.ensure(client.getZookeeperClient()); result.preValue = client.getData().storingStatIn(stat).forPath(path); } catch ( KeeperException.NoNodeException e ) http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/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 0292cde..0fb0219 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 @@ -29,7 +29,7 @@ import org.apache.curator.framework.api.CuratorWatcher; import org.apache.curator.framework.listen.ListenerContainer; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; -import org.apache.curator.utils.EnsurePathContainers; +import org.apache.curator.utils.EnsurePath; import org.apache.curator.utils.PathUtils; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; @@ -57,7 +57,7 @@ public class NodeCache implements Closeable private final CuratorFramework client; private final String path; private final boolean dataIsCompressed; - private final EnsurePathContainers ensurePath; + private final EnsurePath ensurePath; private final AtomicReference data = new AtomicReference(null); private final AtomicReference state = new AtomicReference(State.LATENT); private final ListenerContainer listeners = new ListenerContainer(); @@ -132,7 +132,7 @@ public class NodeCache implements Closeable this.client = client; this.path = PathUtils.validatePath(path); this.dataIsCompressed = dataIsCompressed; - ensurePath = client.newNamespaceAwareEnsurePathContainers(path).excludingLastContainers(); + ensurePath = client.newNamespaceAwareEnsurePath(path).excludingLast(); } /** http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/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 f8fd8db..1cbe7ac 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 @@ -33,7 +33,7 @@ import org.apache.curator.framework.listen.ListenerContainer; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.utils.CloseableExecutorService; -import org.apache.curator.utils.EnsurePathContainers; +import org.apache.curator.utils.EnsurePath; import org.apache.curator.utils.PathUtils; import org.apache.curator.utils.ThreadUtils; import org.apache.curator.utils.ZKPaths; @@ -73,7 +73,7 @@ public class PathChildrenCache implements Closeable private final CloseableExecutorService executorService; private final boolean cacheData; private final boolean dataIsCompressed; - private final EnsurePathContainers ensurePath; + private final EnsurePath ensurePath; private final ListenerContainer listeners = new ListenerContainer(); private final ConcurrentMap currentData = Maps.newConcurrentMap(); private final AtomicReference> initialSet = new AtomicReference>(); @@ -220,7 +220,7 @@ public class PathChildrenCache implements Closeable this.cacheData = cacheData; this.dataIsCompressed = dataIsCompressed; this.executorService = executorService; - ensurePath = client.newNamespaceAwareEnsurePathContainers(path); + ensurePath = client.newNamespaceAwareEnsurePath(path); } /** http://git-wip-us.apache.org/repos/asf/curator/blob/b3cf69d0/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 e577046..a915113 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 @@ -19,7 +19,6 @@ package org.apache.curator.framework.recipes.queue; import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.utils.EnsurePathContainers; import org.apache.curator.utils.PathUtils; import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.CreateMode; @@ -50,7 +49,6 @@ public class SimpleDistributedQueue private final Logger log = LoggerFactory.getLogger(getClass()); private final CuratorFramework client; private final String path; - private final EnsurePathContainers ensurePath; private final String PREFIX = "qn-"; @@ -62,7 +60,6 @@ public class SimpleDistributedQueue { this.client = client; this.path = PathUtils.validatePath(path); - ensurePath = client.newNamespaceAwareEnsurePathContainers(path); } /** @@ -119,10 +116,8 @@ public class SimpleDistributedQueue */ public boolean offer(byte[] data) throws Exception { - ensurePath.ensure(client.getZookeeperClient()); - String thisPath = ZKPaths.makePath(path, PREFIX); - client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(thisPath, data); + client.create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(thisPath, data); return true; } @@ -181,8 +176,6 @@ public class SimpleDistributedQueue private byte[] internalPoll(long timeout, TimeUnit unit) throws Exception { - ensurePath.ensure(client.getZookeeperClient()); - long startMs = System.currentTimeMillis(); boolean hasTimeout = (unit != null); long maxWaitMs = hasTimeout ? TimeUnit.MILLISECONDS.convert(timeout, unit) : Long.MAX_VALUE; @@ -222,8 +215,6 @@ public class SimpleDistributedQueue private byte[] internalElement(boolean removeIt, Watcher watcher) throws Exception { - ensurePath.ensure(client.getZookeeperClient()); - List nodes; try {