CuratorFramework::create
" will return the path of the created zNode.xxxxxxxxxx
org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /path
xxxxxxxxxx
org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists for /path
CONNECT_STRING
" variable with your information.xxxxxxxxxx
final String CONNECT_STRING = "localhost:2181";
final int SESSION_TIMEOUT_MS = Integer.valueOf(60 * 1000);
final int CONNECTION_TIMEOUT_MS = Integer.valueOf(15 * 1000);
final RetryPolicy RETRY_POLICY = new RetryOneTime(1000);
// -- CuratorFrameworkFactory::newClient
final CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(CONNECT_STRING, SESSION_TIMEOUT_MS, CONNECTION_TIMEOUT_MS, RETRY_POLICY);
// -- CuratorFramework::start
curatorFramework.start();
// -- CuratorFramework::create::forPath(path, data)
final String path = "/abc";
final String data = "zNode data ...";
final String result = curatorFramework.create().forPath(path, data.getBytes());
System.out.println(result);
// -- CuratorFramework::close
curatorFramework.close();