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/CURATOR-147 Commit: ae6f4ecb6a43fb438600742a5e7563a5ce385733 Parents: 8929343 Author: Cameron McKenzie <[email protected]> Authored: Mon Sep 15 11:43:48 2014 +1000 Committer: Cameron McKenzie <[email protected]> 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
