[
https://issues.apache.org/jira/browse/CURATOR-280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15648539#comment-15648539
]
Vitalii Tymchyshyn edited comment on CURATOR-280 at 11/8/16 7:29 PM:
---------------------------------------------------------------------
{code}
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]);
}
}{code}
was (Author: tivv):
{code}
@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]);
}
{code}
> LeaderLatch doesn't work when using a zookeeper chroot
> ------------------------------------------------------
>
> Key: CURATOR-280
> URL: https://issues.apache.org/jira/browse/CURATOR-280
> Project: Apache Curator
> Issue Type: Bug
> Components: Framework
> Affects Versions: 2.9.0, 2.9.1
> Reporter: Vincent Bernat
>
> Hey!
> When using a ZK connection-string with a chroot (for example
> {{localhost:2181/chroot}}), the leader election by LeaderLatch doesn't work.
> This may be similar to CURATOR-270. If I query {{.getParticipants}}, I get:
> {code}
> Actual: org.apache.zookeeper.KeeperException$NoNodeException:
> KeeperErrorCode = NoNode for /test4
>
> org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
>
> org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
> org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1590)
>
> org.apache.curator.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:214)
>
> org.apache.curator.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:203)
> org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107)
>
> org.apache.curator.framework.imps.GetChildrenBuilderImpl.pathInForeground(GetChildrenBuilderImpl.java:199)
>
> org.apache.curator.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:191)
>
> org.apache.curator.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:38)
>
> org.apache.curator.framework.recipes.locks.LockInternals.getSortedChildren(LockInternals.java:150)
>
> org.apache.curator.framework.recipes.locks.LockInternals.getParticipantNodes(LockInternals.java:132)
>
> org.apache.curator.framework.recipes.leader.LeaderLatch.getParticipants(LeaderLatch.java:430)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)