Interface ZookeeperClient
- All Known Implementing Classes:
AbstractZookeeperClient
public interface ZookeeperClient
Common abstraction of Zookeeper client.
-
Method Summary
Modifier and TypeMethodDescriptionaddChildListener(String path, ChildListener listener) voidaddDataListener(String path, DataListener listener) Attach data listener to current Zookeeper client.voidaddDataListener(String path, DataListener listener, Executor executor) Attach data listener to current Zookeeper client.voidaddStateListener(StateListener listener) booleancheckExists(String path) voidclose()Close connection to Zookeeper server (cluster).voidCreate ZNode in Zookeeper.voidcreateOrUpdate(String path, String content, boolean ephemeral) Create or update ZNode in Zookeeper with content specified.voidcreateOrUpdate(String path, String content, boolean ephemeral, Integer ticket) CAS version to Create or update ZNode in Zookeeper with content specified.voidDelete ZNode.getChildren(String path) getConfigItem(String path) getContent(String path) Obtain the content of a ZNode.getUrl()booleanCheck the Zookeeper client whether connected to server or not.voidremoveChildListener(String path, ChildListener listener) voidremoveDataListener(String path, DataListener listener) Detach data listener.voidremoveStateListener(StateListener listener)
-
Method Details
-
create
Create ZNode in Zookeeper.- Parameters:
path- path to ZNodeephemeral- specify create mode of ZNode creation. true - EPHEMERAL, false - PERSISTENT.faultTolerant- specify fault tolerance of ZNode creation. true - ignore exception and recreate if is ephemeral, false - throw exception.
-
delete
Delete ZNode.- Parameters:
path- path to ZNode
-
getChildren
-
addChildListener
-
addDataListener
Attach data listener to current Zookeeper client.- Parameters:
path- directory. All children of path will be listened.listener- The data listener object.
-
addDataListener
Attach data listener to current Zookeeper client. The listener will be executed using the given executor.- Parameters:
path- directory. All children of path will be listened.listener- The data listener object.executor- the executor that will execute the listener.
-
removeDataListener
Detach data listener.- Parameters:
path- directory. All listener of children of the path will be detached.listener- The data listener object.
-
removeChildListener
-
addStateListener
-
removeStateListener
-
isConnected
boolean isConnected()Check the Zookeeper client whether connected to server or not.- Returns:
- true if connected
-
close
void close()Close connection to Zookeeper server (cluster). -
getUrl
URL getUrl() -
createOrUpdate
Create or update ZNode in Zookeeper with content specified.- Parameters:
path- path to ZNodecontent- the content of ZNodeephemeral- specify create mode of ZNode creation. true - EPHEMERAL, false - PERSISTENT.
-
createOrUpdate
CAS version to Create or update ZNode in Zookeeper with content specified.- Parameters:
path- path to ZNodecontent- the content of ZNodeephemeral- specify create mode of ZNode creation. true - EPHEMERAL, false - PERSISTENT.ticket- origin content version, if current version is not the specified version, throw exception
-
getContent
Obtain the content of a ZNode.- Parameters:
path- path to ZNode- Returns:
- content of ZNode
-
getConfigItem
-
checkExists
-