Use creatingParentsIfNeeded(). ZooKeeper does not automatically create parent 
nodes.

-JZ


From: Vadim Keylis [email protected]
Reply: [email protected] [email protected]
Date: May 16, 2014 at 5:18:45 PM
To: [email protected] [email protected]
Subject:  Re: How to create znode with curator  

When I run the code I get exception:

org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode 
for /name/offset/event-capture/topic
at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:783)
at 
org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:676)


On Thu, May 15, 2014 at 2:23 PM, Vadim Keylis <[email protected]> wrote:
How do you create a path if it does not exist.
CuratorFramework    client = 
CuratorFrameworkFactory.newClient("dzoo01:2181/kafka", new 
ExponentialBackoffRetry(1000, 3));

path= '/name/offset/event-capture/topic';

I check if path exists
if(curatorFramework.checkExists().forPath(path) == null){
    curatorFramework.create().forPath(path)
}

will that code snippet create znode?


Thanks,
Vadim 

Reply via email to