org.linkedin.zookeeper.client
Interface IZKClient

All Superinterfaces:
IZooKeeper
All Known Implementing Classes:
AbstractZKClient, ChrootedZKClient, ZKClient

public interface IZKClient
extends IZooKeeper


Method Summary
 IZKClient chroot(java.lang.String path)
           
 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)
 boolean isConnected()
           
 void registerListener(LifecycleListener listener)
          Registers a listener for lifecycle management.
 void removeListener(LifecycleListener listener)
          Removes a listener previously set with registerListener(LifecycleListener)
 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 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
 

Method Detail

registerListener

void registerListener(LifecycleListener listener)
Registers a listener for lifecycle management. Due to the nature of ZooKeeper, you should always register a listener and act appropriately on the 2 events that you can receive. Note that it is guaranteed that the listener will be called even if the connection with ZooKeeper has been established a while ago...

Parameters:
listener - the listener

removeListener

void removeListener(LifecycleListener listener)
Removes a listener previously set with registerListener(LifecycleListener)

Parameters:
listener -

chroot

IZKClient chroot(java.lang.String path)
Returns:
a new client with the path that has been chrooted... meaning all paths will be relative to the path provided.

isConnected

boolean isConnected()
Returns:
true if connected

exists

org.apache.zookeeper.data.Stat exists(java.lang.String path)
                                      throws java.lang.InterruptedException,
                                             org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getChildren

java.util.List<java.lang.String> getChildren(java.lang.String path)
                                             throws java.lang.InterruptedException,
                                                    org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKChildren

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

getAllChildren

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.

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

create

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
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createBytesNode

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
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createWithParents

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

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createBytesNodeWithParents

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

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getData

byte[] getData(java.lang.String path)
               throws java.lang.InterruptedException,
                      org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getStringData

java.lang.String getStringData(java.lang.String path)
                               throws java.lang.InterruptedException,
                                      org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKStringData

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

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKStringData

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)

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKByteData

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

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

getZKByteData

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)

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

setData

org.apache.zookeeper.data.Stat setData(java.lang.String path,
                                       java.lang.String data)
                                       throws java.lang.InterruptedException,
                                              org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

setByteData

org.apache.zookeeper.data.Stat setByteData(java.lang.String path,
                                           byte[] data)
                                           throws java.lang.InterruptedException,
                                                  org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

createOrSetWithParents

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.

Returns:
null if create worked, otherwise the result of setData
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

delete

void delete(java.lang.String path)
            throws java.lang.InterruptedException,
                   org.apache.zookeeper.KeeperException
Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException

deleteWithChildren

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

Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException