curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: How to create znode with curator
Date Fri, 16 May 2014 22:19:50 GMT
Use creatingParentsIfNeeded(). ZooKeeper does not automatically create parent nodes.

-JZ


From: Vadim Keylis vkeylis2009@gmail.com
Reply: user@curator.apache.org user@curator.apache.org
Date: May 16, 2014 at 5:18:45 PM
To: user@curator.apache.org user@curator.apache.org
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 <vkeylis2009@gmail.com> 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 


Mime
View raw message