com.netflix.curator.utils
Class EnsurePath
java.lang.Object
com.netflix.curator.utils.EnsurePath
public class EnsurePath
- extends Object
Utility to ensure that a particular path is created.
The first time it is used, a synchronized call to ZKPaths.mkdirs(ZooKeeper, String) is made to
ensure that the entire path has been created (with an empty byte array if needed). Subsequent
calls with the instance are un-synchronized NOPs.
Usage:
EnsurePath ensurePath = new EnsurePath(aFullPathToEnsure);
...
String nodePath = aFullPathToEnsure + "/foo";
ensurePath.ensure(zk); // first time syncs and creates if needed
zk.create(nodePath, ...);
...
ensurePath.ensure(zk); // subsequent times are NOPs
zk.create(nodePath, ...);
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnsurePath
public EnsurePath(String path)
- Parameters:
path - the full path to ensure
ensure
public void ensure(CuratorZookeeperClient client)
throws Exception
- First time, synchronizes and makes sure all nodes in the path are created. Subsequent calls
with this instance are NOPs.
- Parameters:
client - ZK client
- Throws:
Exception - ZK errors
Copyright © 2012. All Rights Reserved.