public class ZKPaths extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ZKPaths.PathAndNode |
Modifier and Type | Field and Description |
---|---|
static String |
PATH_SEPARATOR
Zookeeper's path separator character.
|
Modifier and Type | Method and Description |
---|---|
static void |
deleteChildren(org.apache.zookeeper.ZooKeeper zookeeper,
String path,
boolean deleteSelf)
Recursively deletes children of a node.
|
static String |
extractSequentialSuffix(String path)
Extracts the ten-digit suffix from a sequential znode path.
|
static String |
fixForNamespace(String namespace,
String path)
Apply the namespace to the given path
|
static String |
fixForNamespace(String namespace,
String path,
boolean isSequential)
Apply the namespace to the given path
|
static org.apache.zookeeper.CreateMode |
getContainerCreateMode() |
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.
|
static List<String> |
getSortedChildren(org.apache.zookeeper.ZooKeeper zookeeper,
String path)
Return the children of the given path sorted by sequence number
|
static boolean |
hasContainerSupport()
Returns true if the version of ZooKeeper client in use supports containers
|
static String |
makePath(String parent,
String child)
Given a parent path and a child node, create a combined full path
|
static String |
makePath(String parent,
String firstChild,
String... restChildren)
Given a parent path and a list of children nodes, create a combined full path
|
static void |
mkdirs(org.apache.zookeeper.ZooKeeper zookeeper,
String path)
Make sure all the nodes in the path are created.
|
static void |
mkdirs(org.apache.zookeeper.ZooKeeper zookeeper,
String path,
boolean makeLastNode)
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.
|
static List<String> |
split(String path)
Given a full path, return the the individual parts, without slashes.
|
public static final String PATH_SEPARATOR
public static org.apache.zookeeper.CreateMode getContainerCreateMode()
CreateMode.CONTAINER
if the ZK JAR supports it. Otherwise CreateMode.PERSISTENT
public static boolean hasContainerSupport()
public static String fixForNamespace(String namespace, String path)
namespace
- namespace (can be null)path
- pathpublic static String fixForNamespace(String namespace, String path, boolean isSequential)
namespace
- namespace (can be null)path
- pathisSequential
- if the path is being created with a sequential flagpublic static String getNodeFromPath(String path)
path
- the pathpublic static ZKPaths.PathAndNode getPathAndNode(String path)
path
- the pathpublic static String extractSequentialSuffix(String path)
path
- the path of a sequential znodespublic static List<String> split(String path)
path
- the pathpublic static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path) throws InterruptedException, org.apache.zookeeper.KeeperException
zookeeper
- the clientpath
- path to ensureInterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errorspublic static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode) throws InterruptedException, org.apache.zookeeper.KeeperException
zookeeper
- the clientpath
- path to ensuremakeLastNode
- if true, all nodes are created. If false, only the parent nodes are createdInterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errorspublic static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider) throws InterruptedException, org.apache.zookeeper.KeeperException
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 nodesInterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errorspublic static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider, boolean asContainers) throws InterruptedException, org.apache.zookeeper.KeeperException
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 as CreateMode.CONTAINER
InterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- Zookeeper errorspublic static void deleteChildren(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean deleteSelf) throws InterruptedException, org.apache.zookeeper.KeeperException
zookeeper
- the clientpath
- path of the node to deletedeleteSelf
- flag that indicates that the node should also get deletedInterruptedException
org.apache.zookeeper.KeeperException
public static List<String> getSortedChildren(org.apache.zookeeper.ZooKeeper zookeeper, String path) throws InterruptedException, org.apache.zookeeper.KeeperException
zookeeper
- the clientpath
- the pathInterruptedException
- thread interruptionorg.apache.zookeeper.KeeperException
- zookeeper errorspublic static String makePath(String parent, String child)
parent
- the parentchild
- the childpublic static String makePath(String parent, String firstChild, String... restChildren)
parent
- the parentfirstChild
- the first children in the pathrestChildren
- the rest of the children in the pathCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.