org.linkedin.zookeeper.client
Class AbstractZKClient

java.lang.Object
  extended by org.linkedin.zookeeper.client.AbstractZooKeeper
      extended by org.linkedin.zookeeper.client.AbstractZKClient
All Implemented Interfaces:
IZKClient, IZooKeeper
Direct Known Subclasses:
ChrootedZKClient, ZKClient

public abstract class AbstractZKClient
extends AbstractZooKeeper
implements IZKClient


Field Summary
static org.slf4j.Logger log
           
static java.lang.String MODULE
           
 
Constructor Summary
AbstractZKClient(java.lang.String chroot)
          Constructor
 
Method Summary
 void create(java.lang.String path, java.lang.String data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
           
 void createBytesNode(java.lang.String path, byte[] data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
           
 void createBytesNodeWithParents(java.lang.String path, byte[] data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
          Creates the parents if they don't exist
 org.apache.zookeeper.data.Stat createOrSetWithParents(java.lang.String path, java.lang.String data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
          Tries to create first and if the node exists, then does a setData.
 void createWithParents(java.lang.String path, java.lang.String data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
          Creates the parents if they don't exist
 void delete(java.lang.String path)
           
 void deleteWithChildren(java.lang.String path)
          delete all the children if they exist
 org.apache.zookeeper.data.Stat exists(java.lang.String path)
           
 java.util.List<java.lang.String> getAllChildren(java.lang.String path)
          Returns all the children (recursively) of the provided path.
 java.util.List<java.lang.String> getChildren(java.lang.String path)
           
 byte[] getData(java.lang.String path)
           
 java.lang.String getStringData(java.lang.String path)
           
 ZKData<byte[]> getZKByteData(java.lang.String path)
          Returns both the data as a byte[] as well as the stat
 ZKData<byte[]> getZKByteData(java.lang.String path, org.apache.zookeeper.Watcher watcher)
          Returns both the data as a byte[] as well as the stat (and sets a watcher if not null)
 ZKChildren getZKChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher)
           
 ZKData<java.lang.String> getZKStringData(java.lang.String path)
          Returns both the data as a string as well as the stat
 ZKData<java.lang.String> getZKStringData(java.lang.String path, org.apache.zookeeper.Watcher watcher)
          Returns both the data as a string as well as the stat (and sets a watcher if not null)
 org.apache.zookeeper.data.Stat setByteData(java.lang.String path, byte[] data)
           
 org.apache.zookeeper.data.Stat setData(java.lang.String path, java.lang.String data)
           
 
Methods inherited from class org.linkedin.zookeeper.client.AbstractZooKeeper
addAuthInfo, adjustPath, adjustPath, close, create, create, delete, delete, exists, exists, exists, exists, getACL, getACL, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getData, getData, getData, getData, getSessionId, getSessionPasswd, getSessionTimeout, getState, getZk, register, setACL, setACL, setData, setData, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.linkedin.zookeeper.client.IZKClient
chroot, isConnected, registerListener, removeListener
 
Methods inherited from interface org.linkedin.zookeeper.client.IZooKeeper
addAuthInfo, close, create, create, delete, delete, exists, exists, exists, exists, getACL, getACL, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getData, getData, getData, getData, getSessionId, getSessionPasswd, getSessionTimeout, getState, register, setACL, setACL, setData, setData, sync
 

Field Detail

MODULE

public static final java.lang.String MODULE

log

public static final org.slf4j.Logger log
Constructor Detail

AbstractZKClient

public AbstractZKClient(java.lang.String chroot)
Constructor

Method Detail

exists

public org.apache.zookeeper.data.Stat exists(java.lang.String path)
                                      throws java.lang.InterruptedException,
                                             org.apache.zookeeper.KeeperException
Specified by:
exists in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getChildren

public java.util.List<java.lang.String> getChildren(java.lang.String path)
                                             throws java.lang.InterruptedException,
                                                    org.apache.zookeeper.KeeperException
Specified by:
getChildren in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKChildren

public ZKChildren getZKChildren(java.lang.String path,
                                org.apache.zookeeper.Watcher watcher)
                         throws org.apache.zookeeper.KeeperException,
                                java.lang.InterruptedException
Specified by:
getZKChildren in interface IZKClient
Returns:
both children and stat in one object
Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException

getAllChildren

public java.util.List<java.lang.String> getAllChildren(java.lang.String path)
                                                throws java.lang.InterruptedException,
                                                       org.apache.zookeeper.KeeperException
Returns all the children (recursively) of the provided path. Note that like getChildren(String) the result is relative to path.

Specified by:
getAllChildren in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

create

public void create(java.lang.String path,
                   java.lang.String data,
                   java.util.List<org.apache.zookeeper.data.ACL> acl,
                   org.apache.zookeeper.CreateMode createMode)
            throws java.lang.InterruptedException,
                   org.apache.zookeeper.KeeperException
Specified by:
create in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createBytesNode

public void createBytesNode(java.lang.String path,
                            byte[] data,
                            java.util.List<org.apache.zookeeper.data.ACL> acl,
                            org.apache.zookeeper.CreateMode createMode)
                     throws java.lang.InterruptedException,
                            org.apache.zookeeper.KeeperException
Specified by:
createBytesNode in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createWithParents

public void createWithParents(java.lang.String path,
                              java.lang.String data,
                              java.util.List<org.apache.zookeeper.data.ACL> acl,
                              org.apache.zookeeper.CreateMode createMode)
                       throws java.lang.InterruptedException,
                              org.apache.zookeeper.KeeperException
Creates the parents if they don't exist

Specified by:
createWithParents in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createBytesNodeWithParents

public void createBytesNodeWithParents(java.lang.String path,
                                       byte[] data,
                                       java.util.List<org.apache.zookeeper.data.ACL> acl,
                                       org.apache.zookeeper.CreateMode createMode)
                                throws java.lang.InterruptedException,
                                       org.apache.zookeeper.KeeperException
Creates the parents if they don't exist

Specified by:
createBytesNodeWithParents in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getData

public byte[] getData(java.lang.String path)
               throws java.lang.InterruptedException,
                      org.apache.zookeeper.KeeperException
Specified by:
getData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getStringData

public java.lang.String getStringData(java.lang.String path)
                               throws java.lang.InterruptedException,
                                      org.apache.zookeeper.KeeperException
Specified by:
getStringData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKStringData

public ZKData<java.lang.String> getZKStringData(java.lang.String path)
                                         throws java.lang.InterruptedException,
                                                org.apache.zookeeper.KeeperException
Returns both the data as a string as well as the stat

Specified by:
getZKStringData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKStringData

public ZKData<java.lang.String> getZKStringData(java.lang.String path,
                                                org.apache.zookeeper.Watcher watcher)
                                         throws java.lang.InterruptedException,
                                                org.apache.zookeeper.KeeperException
Returns both the data as a string as well as the stat (and sets a watcher if not null)

Specified by:
getZKStringData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKByteData

public ZKData<byte[]> getZKByteData(java.lang.String path)
                             throws java.lang.InterruptedException,
                                    org.apache.zookeeper.KeeperException
Returns both the data as a byte[] as well as the stat

Specified by:
getZKByteData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKByteData

public ZKData<byte[]> getZKByteData(java.lang.String path,
                                    org.apache.zookeeper.Watcher watcher)
                             throws java.lang.InterruptedException,
                                    org.apache.zookeeper.KeeperException
Returns both the data as a byte[] as well as the stat (and sets a watcher if not null)

Specified by:
getZKByteData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

setData

public org.apache.zookeeper.data.Stat setData(java.lang.String path,
                                              java.lang.String data)
                                       throws java.lang.InterruptedException,
                                              org.apache.zookeeper.KeeperException
Specified by:
setData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

setByteData

public org.apache.zookeeper.data.Stat setByteData(java.lang.String path,
                                                  byte[] data)
                                           throws java.lang.InterruptedException,
                                                  org.apache.zookeeper.KeeperException
Specified by:
setByteData in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createOrSetWithParents

public org.apache.zookeeper.data.Stat createOrSetWithParents(java.lang.String path,
                                                             java.lang.String data,
                                                             java.util.List<org.apache.zookeeper.data.ACL> acl,
                                                             org.apache.zookeeper.CreateMode createMode)
                                                      throws java.lang.InterruptedException,
                                                             org.apache.zookeeper.KeeperException
Tries to create first and if the node exists, then does a setData.

Specified by:
createOrSetWithParents in interface IZKClient
Returns:
null if create worked, otherwise the result of setData
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

delete

public void delete(java.lang.String path)
            throws java.lang.InterruptedException,
                   org.apache.zookeeper.KeeperException
Specified by:
delete in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

deleteWithChildren

public void deleteWithChildren(java.lang.String path)
                        throws java.lang.InterruptedException,
                               org.apache.zookeeper.KeeperException
delete all the children if they exist

Specified by:
deleteWithChildren in interface IZKClient
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException