curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Techy Teck <comptechge...@gmail.com>
Subject Re: Create znodes if it doesn't exists?
Date Fri, 08 Nov 2013 00:14:34 GMT
I see.. So In general how to avoid these kind of problems? is there any
other solution?

And also using Curator for Zookeeper is a good option or Java client
embedded within Zookeeper is a good option?


On Thu, Nov 7, 2013 at 3:34 PM, Jordan Zimmerman <jordan@jordanzimmerman.com
> wrote:

> 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 <comptechgeeky@gmail.com> 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?
>
>

Mime
View raw message