org.apache.curator.utils
Class ZKPaths

java.lang.Object
  extended by org.apache.curator.utils.ZKPaths

public class ZKPaths
extends Object


Nested Class Summary
static class ZKPaths.PathAndNode
           
 
Method Summary
static void deleteChildren(org.apache.zookeeper.ZooKeeper zookeeper, String path, boolean deleteSelf)
          Recursively deletes children of a node.
static String fixForNamespace(String namespace, String path)
          Apply the namespace to the given path
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 String makePath(String parent, String child)
          Given a parent path and a child node, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fixForNamespace

public static String fixForNamespace(String namespace,
                                     String path)
Apply the namespace to the given path

Parameters:
namespace - namespace (can be null)
path - path
Returns:
adjusted path

getNodeFromPath

public static String getNodeFromPath(String path)
Given a full path, return the node name. i.e. "/one/two/three" will return "three"

Parameters:
path - the path
Returns:
the node

getPathAndNode

public static ZKPaths.PathAndNode getPathAndNode(String path)
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

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 client
path - path to ensure
Throws:
InterruptedException - thread interruption
org.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 client
path - path to ensure
makeLastNode - if true, all nodes are created. If false, only the parent nodes are created
Throws:
InterruptedException - thread interruption
org.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 client
path - path to ensure
makeLastNode - if true, all nodes are created. If false, only the parent nodes are created
aclProvider - if not null, the ACL provider to use when creating parent nodes
Throws:
InterruptedException - thread interruption
org.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 client
path - path of the node to delete
deleteSelf - 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 client
path - the path
Returns:
sorted list of children
Throws:
InterruptedException - thread interruption
org.apache.zookeeper.KeeperException - zookeeper errors

makePath

public static String makePath(String parent,
                              String child)
Given a parent path and a child node, create a combined full path

Parameters:
parent - the parent
child - the child
Returns:
full path


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.