com.netflix.curator.utils
Class ZKPaths

java.lang.Object
  extended by com.netflix.curator.utils.ZKPaths

public class ZKPaths
extends java.lang.Object


Nested Class Summary
static class ZKPaths.PathAndNode
           
 
Method Summary
static java.lang.String fixForNamespace(java.lang.String namespace, java.lang.String path)
          Apply the namespace to the given path
static java.lang.String getNodeFromPath(java.lang.String path)
          Given a full path, return the node name.
static ZKPaths.PathAndNode getPathAndNode(java.lang.String path)
          Given a full path, return the node name and its path.
static java.util.List<java.lang.String> getSortedChildren(org.apache.zookeeper.ZooKeeper zookeeper, java.lang.String path)
          Return the children of the given path sorted by sequence number
static java.lang.String makePath(java.lang.String parent, java.lang.String child)
          Given a parent path and a child node, create a combined full path
static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, java.lang.String path)
          Make sure all the nodes in the path are created.
static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper, java.lang.String path, boolean makeLastNode)
          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 java.lang.String fixForNamespace(java.lang.String namespace,
                                               java.lang.String path)
Apply the namespace to the given path

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

getNodeFromPath

public static java.lang.String getNodeFromPath(java.lang.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(java.lang.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,
                          java.lang.String path)
                   throws java.lang.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:
java.lang.InterruptedException - thread interruption
org.apache.zookeeper.KeeperException - Zookeeper errors

mkdirs

public static void mkdirs(org.apache.zookeeper.ZooKeeper zookeeper,
                          java.lang.String path,
                          boolean makeLastNode)
                   throws java.lang.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:
java.lang.InterruptedException - thread interruption
org.apache.zookeeper.KeeperException - Zookeeper errors

getSortedChildren

public static java.util.List<java.lang.String> getSortedChildren(org.apache.zookeeper.ZooKeeper zookeeper,
                                                                 java.lang.String path)
                                                          throws java.lang.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:
java.lang.InterruptedException - thread interruption
org.apache.zookeeper.KeeperException - zookeeper errors

makePath

public static java.lang.String makePath(java.lang.String parent,
                                        java.lang.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