curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Techy Teck <comptechge...@gmail.com>
Subject Create znodes if it doesn't exists?
Date Thu, 07 Nov 2013 22:59:00 GMT
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