Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
In Zookeeper there is no guaranty that "/" would exist. In a case when chroot feature is used, "/" path may not exists.
Currently Curator incorrectly assumes that "/" always exists. It leads to NoNodeException when there is no "/" available.
E.g. see CURATOR-280 for example.
A solution would be to create "/" in ZKPaths#mkdirs.
Primary concern is that it would slow down general case when entity name do not have path separator. Currently it does not require any additional calls, now "/" check would be needed.
A solution can be to change logic to create parents only if NoNode received for node creation call. This would also speed up all the cases where entity name has separator, including when namespaces are used.
Test:
public class TestChroot { private TestingServer server = new TestingServer(); public TestChroot() throws Exception { } @Test public void testCurator() throws Exception { CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString() + "/chrootCurator", new RetryOneTime(1000)); client.start(); client.create().creatingParentsIfNeeded().forPath("/test", new byte[]{1}); Assert.assertEquals(1, client.getData().forPath("/test")[0]); } @Test public void testZookeeper() throws Exception { CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString() + "/chrootZoo", new RetryOneTime(1000)); client.start(); ZooKeeper zooKeeper = client.getZookeeperClient().getZooKeeper(); zooKeeper.create("/", new byte[]{}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); zooKeeper.create("/test", new byte[]{1}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); Assert.assertEquals(1, client.getData().forPath("/test")[0]); } }
Attachments
Issue Links
- breaks
-
CURATOR-280 LeaderLatch doesn't work when using a zookeeper chroot
- Closed
- duplicates
-
CURATOR-50 CreateBuilderImpl fails on forPath if connectString features a chroot that does not already exist.
- Closed
- supercedes
-
CURATOR-280 LeaderLatch doesn't work when using a zookeeper chroot
- Closed