curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsi...@apache.org
Subject [25/41] curator git commit: Use new APIs to ensure path
Date Mon, 17 Aug 2015 17:02:33 GMT
Use new APIs to ensure path


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

Branch: refs/heads/CURATOR-3.0
Commit: df8ec866d5caf01a16e97ffaca26c35220baa019
Parents: f18f876
Author: randgalt <randgalt@apache.org>
Authored: Wed Jul 1 17:50:00 2015 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Wed Jul 1 17:50:00 2015 -0500

----------------------------------------------------------------------
 .../org/apache/curator/framework/imps/NamespaceImpl.java  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/df8ec866/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 03411a2..b0dda5c 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
@@ -21,12 +21,13 @@ package org.apache.curator.framework.imps;
 import org.apache.curator.utils.EnsurePath;
 import org.apache.curator.utils.PathUtils;
 import org.apache.curator.utils.ZKPaths;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 class NamespaceImpl
 {
     private final CuratorFrameworkImpl client;
     private final String namespace;
-    private final EnsurePath ensurePath;
+    private final AtomicBoolean ensurePathNeeded;
 
     NamespaceImpl(CuratorFrameworkImpl client, String namespace)
     {
@@ -44,7 +45,7 @@ class NamespaceImpl
 
         this.client = client;
         this.namespace = namespace;
-        ensurePath = (namespace != null) ? new EnsurePath(ZKPaths.makePath("/", namespace))
: null;
+        ensurePathNeeded = new AtomicBoolean(namespace != null);
     }
 
     String getNamespace()
@@ -67,11 +68,12 @@ class NamespaceImpl
 
     String    fixForNamespace(String path, boolean isSequential)
     {
-        if ( ensurePath != null )
+        if ( ensurePathNeeded.get() )
         {
             try
             {
-                ensurePath.ensure(client.getZookeeperClient());
+                client.createContainers(ZKPaths.makePath("/", namespace));
+                ensurePathNeeded.set(false);
             }
             catch ( Exception e )
             {


Mime
View raw message