Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-357

creatingParentsIfNeeded do not create "/"

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • Framework
    • 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

          Activity

            People

              Unassigned Unassigned
              tivv Vitalii Tymchyshyn
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: