curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Blum (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CURATOR-128) There is no namespace-safe way to refer to the root node
Date Tue, 29 Jul 2014 15:47:39 GMT

    [ https://issues.apache.org/jira/browse/CURATOR-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14077855#comment-14077855
] 

Scott Blum commented on CURATOR-128:
------------------------------------

Sure let me give a very concrete problem this is causing.

I'm using the TreeCache (CURATOR-33) to mirror a ZK tree or subtree out to the local filesystem
(like zkfuse, but it just actively mirrors to the local disk instead of being a FUSE partition).

Sometimes I'd like to mirror a subtree out to disk using its full path in ZK, e.g. `new TreeCache(client,
"/ldap/users", false)` such that the event stream has paths all prefixed with "/ldap/users".
 But other times I want to namespace the incoming client to shorten the mirrored paths, e.g.
`new TreeCache(client.usingNamespace("ldap/users"), "/", false)`.

That second formulation, I can't make it work right now because there's no way to address
the root node of a namespace such that it combines correctly.  I can provide more extensive
test cases to demo the problem if that would be helpful.



> There is no namespace-safe way to refer to the root node
> --------------------------------------------------------
>
>                 Key: CURATOR-128
>                 URL: https://issues.apache.org/jira/browse/CURATOR-128
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Framework
>            Reporter: Scott Blum
>
> Add the following test to TestNamespaceFacade:
> {code}
>     @Test
>     public void     testRootAccess() throws Exception
>     {
>         CuratorFramework    client = CuratorFrameworkFactory.newClient(server.getConnectString(),
new RetryOneTime(1));
>         try
>         {
>             client.start();
>             client.create().forPath("/one");
>             Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/one",
false));
>             Assert.assertNotNull(client.checkExists().forPath("/"));
>             try
>             {
>                 client.checkExists().forPath("");
>                 Assert.fail("IllegalArgumentException expected");
>             }
>             catch ( IllegalArgumentException expected )
>             {
>             }
>             Assert.assertNotNull(client.usingNamespace("one").checkExists().forPath(""));
>             try
>             {
>                 client.usingNamespace("one").checkExists().forPath("/");
>                 Assert.fail("IllegalArgumentException expected");
>             }
>             catch ( IllegalArgumentException expected )
>             {
>             }
>         }
>         finally
>         {
>             CloseableUtils.closeQuietly(client);
>         }
>     }
> {code}
> This tests PASSES, which means that there's no canonical way to refer to the root node.
 If the client is not namespaced, "/" works and "" does not work.  If the client is namespaced,
"" works and "/" does not.
> In either case, I think ZKPaths.makePath mishandles certain cases.
> If you append "/foo" and "/" the result is "/foo/" which is an invalid path.
> On the other hand, if you append "" and "bar" the result is "//bar" which is also invalid.
> What's the right behavior here?  Does the root node / root of a namespace always need
to be referred to as "/" or is empty string an acceptable alias?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message