curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <>
Subject Re: Create znodes if it doesn't exists?
Date Thu, 07 Nov 2013 23:34:20 GMT
There's been some talk of adding APIs like that to Curator, but it doesn't have it now.

On Nov 7, 2013, at 2:59 PM, Techy Teck <> wrote:

> I am creating couple of nodes using Apache Curator like below - 
>     private static void createZnodes(CuratorFramework client) throws Exception {
>         client.create().creatingParentsIfNeeded().forPath(ZookConstants.COLO_DC1_0, "".getBytes());
>         // some other node here
>     }
> Now suppose if I have ran my program for the first time, then it will create the above
nodes.. But suppose if I am running my same program again, it will throw the exception like
this - 
>     org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists
for /tt/colo/dc1/e0
> Is there any way to check if the node exists then don't create it to avoid the exception?
> There should be some method which should check if the nodes exists already, then dont
create it. If it doesn't exists then create it.. Is there anything like in Curator?

View raw message