You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2014/09/15 09:01:45 UTC

[1/3] git commit: CURATOR-147 Remove use of deprecated APIs

Repository: curator
Updated Branches:
  refs/heads/master f9c69199b -> b66e9b6a7


CURATOR-147 Remove use of deprecated APIs


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

Branch: refs/heads/master
Commit: 8929343e22e51d1c109fe4143327d3c3958077f3
Parents: f9c6919
Author: Mike Drob <md...@cloudera.com>
Authored: Thu Sep 11 16:03:06 2014 -0700
Committer: Mike Drob <md...@cloudera.com>
Committed: Thu Sep 11 16:03:06 2014 -0700

----------------------------------------------------------------------
 .../org/apache/curator/framework/imps/FailedDeleteManager.java   | 2 +-
 .../java/org/apache/curator/framework/imps/TestMultiClient.java  | 2 +-
 .../org/apache/curator/framework/imps/TestNamespaceFacade.java   | 4 ++--
 .../java/org/apache/curator/framework/imps/TestTransactions.java | 2 +-
 .../apache/curator/framework/recipes/queue/DistributedQueue.java | 4 +++-
 .../framework/recipes/leader/TestLeaderSelectorCluster.java      | 2 +-
 .../framework/recipes/queue/TestBoundedDistributedQueue.java     | 3 ++-
 7 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
index f02e852..deb7f40 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
@@ -47,7 +47,7 @@ class FailedDeleteManager
         }
         
         
-        if ( client.isStarted() )
+        if ( client.getState() == CuratorFrameworkState.STARTED )
         {
             log.debug("Path being added to guaranteed delete set: " + path);
             try

http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
index 1d7634b..de210ab 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestMultiClient.java
@@ -87,7 +87,7 @@ public class TestMultiClient extends BaseClassForTests
                 }
             );
 
-            client2.sync("/test", null);
+            client2.sync().forPath("/test");
 
             Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
         }

http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
index 475e7e9..d09dd18 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java
@@ -185,10 +185,10 @@ public class TestNamespaceFacade extends BaseClassForTests
         client.start();
         CuratorFramework    namespaced = client.usingNamespace(null);
 
-        Assert.assertEquals(client.isStarted(), namespaced.isStarted());
+        Assert.assertEquals(client.getState(), namespaced.getState(), "Namespaced state did not match true state after call to start.");
 
         client.close();
-        Assert.assertEquals(client.isStarted(), namespaced.isStarted());
+        Assert.assertEquals(client.getState(), namespaced.getState(), "Namespaced state did not match true state after call to close.");
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java
index 3b7e062..ae2cf1d 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java
@@ -90,7 +90,7 @@ public class TestTransactions extends BaseClassForTests
                     .commit();
 
             Assert.assertTrue(client.checkExists().forPath("/foo") != null);
-            Assert.assertTrue(client.nonNamespaceView().checkExists().forPath("/galt/foo") != null);
+            Assert.assertTrue(client.usingNamespace(null).checkExists().forPath("/galt/foo") != null);
             Assert.assertEquals(client.getData().forPath("/foo"), "two".getBytes());
             Assert.assertTrue(client.checkExists().forPath("/foo/bar") == null);
 

http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
index 671bea9..7b4e877 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
@@ -22,11 +22,13 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.api.BackgroundCallback;
 import org.apache.curator.framework.api.CuratorEvent;
 import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.imps.CuratorFrameworkState;
 import org.apache.curator.framework.listen.ListenerContainer;
 import org.apache.curator.framework.recipes.leader.LeaderSelector;
 import org.apache.curator.utils.ZKPaths;
@@ -702,7 +704,7 @@ public class DistributedQueue<T> implements QueueBase<T>
             {
                 bytes = client.getData().storingStatIn(stat).forPath(itemPath);
             }
-            if ( client.isStarted() )
+            if ( client.getState() == CuratorFrameworkState.STARTED )
             {
                 client.delete().withVersion(stat.getVersion()).forPath(itemPath);
             }

http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
index 8f5d858..48d933f 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelectorCluster.java
@@ -96,7 +96,7 @@ public class TestLeaderSelectorCluster
         {
             client = CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
             client.start();
-            client.sync("/", null);
+            client.sync().forPath("/");
 
             final AtomicReference<Exception>        error = new AtomicReference<Exception>(null);
             final AtomicReference<String>           lockNode = new AtomicReference<String>(null);

http://git-wip-us.apache.org/repos/asf/curator/blob/8929343e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
index edae618..973ef51 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestBoundedDistributedQueue.java
@@ -20,6 +20,7 @@ package org.apache.curator.framework.recipes.queue;
 
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.imps.CuratorFrameworkState;
 import org.apache.curator.framework.state.ConnectionState;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
@@ -115,7 +116,7 @@ public class TestBoundedDistributedQueue extends BaseClassForTests
                             }
                         };
 
-                        while ( !Thread.currentThread().isInterrupted() && client.isStarted() && !isDone.get() )
+                        while ( !Thread.currentThread().isInterrupted() && client.getState() == CuratorFrameworkState.STARTED && !isDone.get() )
                         {
                             synchronized(lock)
                             {


[2/3] git commit: CURATOR-147 - Modified the Curator framework so that it doesn't use isStarted() internally. Marked isStarted() and nonNamespaceView() as null in the Impl class. Modified the TestFramework so that it doesn't use the deprectated nonNamesp

Posted by ca...@apache.org.
CURATOR-147 - Modified the Curator framework so that it doesn't use
isStarted() internally. Marked isStarted() and nonNamespaceView() as null
in the Impl class. Modified the TestFramework so that it doesn't use the
deprectated nonNamespaceView.


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

Branch: refs/heads/master
Commit: ae6f4ecb6a43fb438600742a5e7563a5ce385733
Parents: 8929343
Author: Cameron McKenzie <ca...@unico.com.au>
Authored: Mon Sep 15 11:43:48 2014 +1000
Committer: Cameron McKenzie <ca...@unico.com.au>
Committed: Mon Sep 15 11:43:48 2014 +1000

----------------------------------------------------------------------
 .../framework/imps/CuratorFrameworkImpl.java    | 24 +++++++++++---------
 .../curator/framework/imps/TestFramework.java   |  4 ++--
 2 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/ae6f4ecb/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 fbe1ec7..cf38e21 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
@@ -214,6 +214,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     }
 
     @Override
+    @Deprecated
     public boolean isStarted()
     {
         return state.get() == CuratorFrameworkState.STARTED;
@@ -326,6 +327,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     }
 
     @Override
+    @Deprecated
     public CuratorFramework nonNamespaceView()
     {
         return usingNamespace(null);
@@ -341,7 +343,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public CuratorFramework usingNamespace(String newNamespace)
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return namespaceFacadeCache.get(newNamespace);
     }
@@ -349,7 +351,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public CreateBuilder create()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new CreateBuilderImpl(this);
     }
@@ -357,7 +359,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public DeleteBuilder delete()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new DeleteBuilderImpl(this);
     }
@@ -365,7 +367,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public ExistsBuilder checkExists()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new ExistsBuilderImpl(this);
     }
@@ -373,7 +375,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public GetDataBuilder getData()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new GetDataBuilderImpl(this);
     }
@@ -381,7 +383,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public SetDataBuilder setData()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new SetDataBuilderImpl(this);
     }
@@ -389,7 +391,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public GetChildrenBuilder getChildren()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new GetChildrenBuilderImpl(this);
     }
@@ -397,7 +399,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public GetACLBuilder getACL()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new GetACLBuilderImpl(this);
     }
@@ -405,7 +407,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public SetACLBuilder setACL()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new SetACLBuilderImpl(this);
     }
@@ -413,7 +415,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public CuratorTransaction inTransaction()
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         return new CuratorTransactionImpl(this);
     }
@@ -439,7 +441,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
     @Override
     public void sync(String path, Object context)
     {
-        Preconditions.checkState(isStarted(), "instance must be started before calling this method");
+        Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method");
 
         path = fixForNamespace(path);
 

http://git-wip-us.apache.org/repos/asf/curator/blob/ae6f4ecb/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 2bd6053..5a640db 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
@@ -342,7 +342,7 @@ public class TestFramework extends BaseClassForTests
             Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/" + namespace + "/test", false));
             Assert.assertNull(client.getZookeeperClient().getZooKeeper().exists("/test", false));
 
-            actualPath = client.nonNamespaceView().create().forPath("/non");
+            actualPath = client.usingNamespace(null).create().forPath("/non");
             Assert.assertEquals(actualPath, "/non");
             Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/non", false));
 
@@ -350,7 +350,7 @@ public class TestFramework extends BaseClassForTests
             byte[]      bytes = client.getData().forPath("/test/child");
             Assert.assertEquals(bytes, "hey".getBytes());
 
-            bytes = client.nonNamespaceView().getData().forPath("/" + namespace + "/test/child");
+            bytes = client.usingNamespace(null).getData().forPath("/" + namespace + "/test/child");
             Assert.assertEquals(bytes, "hey".getBytes());
         }
         finally


[3/3] git commit: CURATOR-147 - Fixed up isStarted() call

Posted by ca...@apache.org.
CURATOR-147 - Fixed up isStarted() call


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

Branch: refs/heads/master
Commit: b66e9b6a7afbbb9fc0a95adada26c9f774a54c13
Parents: ae6f4ec
Author: Cameron McKenzie <ca...@unico.com.au>
Authored: Mon Sep 15 16:57:25 2014 +1000
Committer: Cameron McKenzie <ca...@unico.com.au>
Committed: Mon Sep 15 16:57:25 2014 +1000

----------------------------------------------------------------------
 .../java/org/apache/curator/framework/imps/CreateBuilderImpl.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/b66e9b6a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
index 70b92ab..d74cc56 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
@@ -771,7 +771,7 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperation<PathAndByt
      */
     private void findAndDeleteProtectedNodeInBackground(String path, String protectedId, FindProtectedNodeCB callback)
     {
-        if ( client.isStarted() )
+        if ( client.getState() == CuratorFrameworkState.STARTED )
         {
             if ( callback == null )
             {