Package org.apache.curator.utils
Class ZKPaths
java.lang.Object
org.apache.curator.utils.ZKPaths
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteChildren
(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean deleteSelf) Recursively deletes children of a node.static String
Extracts the ten-digit suffix from a sequential znode path.static String
fixForNamespace
(String namespace, String path) Apply the namespace to the given pathstatic String
fixForNamespace
(String namespace, String path, boolean isSequential) Apply the namespace to the given pathstatic org.apache.zookeeper.CreateMode
static String
getNodeFromPath
(String path) Given a full path, return the node name.static ZKPaths.PathAndNode
getPathAndNode
(String path) Given a full path, return the node name and its path.getSortedChildren
(org.apache.zookeeper.ZooKeeper zookeeper, String path) Return the children of the given path sorted by sequence numberstatic boolean
Returns true if the version of ZooKeeper client in use supports containersstatic String
Given a parent path and a child node, create a combined full pathstatic String
Given a parent path and a list of children nodes, create a combined full pathstatic void
Make sure all the nodes in the path are created.static void
Make sure all the nodes in the path are created.static void
mkdirs
(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider) Make sure all the nodes in the path are created.static void
mkdirs
(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider, boolean asContainers) Make sure all the nodes in the path are created.Given a full path, return the the individual parts, without slashes.
-
Field Details
-
PATH_SEPARATOR
Zookeeper's path separator character.- See Also:
-
-
Method Details
-
getContainerCreateMode
public static org.apache.zookeeper.CreateMode getContainerCreateMode()- Returns:
CreateMode.CONTAINER
if the ZK JAR supports it. OtherwiseCreateMode.PERSISTENT
-
hasContainerSupport
public static boolean hasContainerSupport()Returns true if the version of ZooKeeper client in use supports containers- Returns:
- true/false
-
fixForNamespace
Apply the namespace to the given path- Parameters:
namespace
- namespace (can be null)path
- path- Returns:
- adjusted path
-
fixForNamespace
Apply the namespace to the given path- Parameters:
namespace
- namespace (can be null)path
- pathisSequential
- if the path is being created with a sequential flag- Returns:
- adjusted path
-
getNodeFromPath
Given a full path, return the node name. i.e. "/one/two/three" will return "three"- Parameters:
path
- the path- Returns:
- the node
-
getPathAndNode
Given a full path, return the node name and its path. i.e. "/one/two/three" will return {"/one/two", "three"}- Parameters:
path
- the path- Returns:
- the node
-
extractSequentialSuffix
Extracts the ten-digit suffix from a sequential znode path. Does not currently perform validation on the provided path; it will just return a string comprising the last ten characters.- Parameters:
path
- the path of a sequential znodes- Returns:
- the sequential suffix
-
split
Given a full path, return the the individual parts, without slashes. The root path will return an empty list.- Parameters:
path
- the path- Returns:
- an array of parts
-
mkdirs
public static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path) throws InterruptedException, org.apache.zookeeper.KeeperException Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish between directories and files. So, every node in the path is created. The data for each node is an empty blob- Parameters:
zookeeper
- the clientpath
- path to ensure- Throws:
InterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errors
-
mkdirs
public static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode) throws InterruptedException, org.apache.zookeeper.KeeperException Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish between directories and files. So, every node in the path is created. The data for each node is an empty blob- Parameters:
zookeeper
- the clientpath
- path to ensuremakeLastNode
- if true, all nodes are created. If false, only the parent nodes are created- Throws:
InterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errors
-
mkdirs
public static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider) throws InterruptedException, org.apache.zookeeper.KeeperException Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish between directories and files. So, every node in the path is created. The data for each node is an empty blob- Parameters:
zookeeper
- the clientpath
- path to ensuremakeLastNode
- if true, all nodes are created. If false, only the parent nodes are createdaclProvider
- if not null, the ACL provider to use when creating parent nodes- Throws:
InterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errors
-
mkdirs
public static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider, boolean asContainers) throws InterruptedException, org.apache.zookeeper.KeeperException Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish between directories and files. So, every node in the path is created. The data for each node is an empty blob- Parameters:
zookeeper
- the clientpath
- path to ensuremakeLastNode
- if true, all nodes are created. If false, only the parent nodes are createdaclProvider
- if not null, the ACL provider to use when creating parent nodesasContainers
- if true, nodes are created asCreateMode.CONTAINER
- Throws:
InterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errors
-
deleteChildren
public static void deleteChildren(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean deleteSelf) throws InterruptedException, org.apache.zookeeper.KeeperException Recursively deletes children of a node.- Parameters:
zookeeper
- the clientpath
- path of the node to deletedeleteSelf
- flag that indicates that the node should also get deleted- Throws:
InterruptedException
org.apache.zookeeper.KeeperException
-
getSortedChildren
public static List<String> getSortedChildren(org.apache.zookeeper.ZooKeeper zookeeper, String path) throws InterruptedException, org.apache.zookeeper.KeeperException Return the children of the given path sorted by sequence number- Parameters:
zookeeper
- the clientpath
- the path- Returns:
- sorted list of children
- Throws:
InterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- zookeeper errors
-
makePath
Given a parent path and a child node, create a combined full path- Parameters:
parent
- the parentchild
- the child- Returns:
- full path
-
makePath
Given a parent path and a list of children nodes, create a combined full path- Parameters:
parent
- the parentfirstChild
- the first children in the pathrestChildren
- the rest of the children in the path- Returns:
- full path
-