public class ZkClient extends Object implements org.apache.zookeeper.Watcher
Constructor and Description |
---|
ZkClient() |
ZkClient(int sessionTimeout,
int maxRetries,
int retryIntervalMillis) |
ZkClient(String zkhost,
int zkport) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
connect() |
String |
create(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode)
NONSEQUENTIAL create is idempotent operation.
|
void |
create(String path,
String value,
boolean ephemeral) |
void |
delete(String path,
int version)
delete is an idempotent operation.
|
org.apache.zookeeper.data.Stat |
exists(String path,
boolean watch)
exists is an idempotent operation.
|
org.apache.zookeeper.data.Stat |
exists(String path,
org.apache.zookeeper.Watcher watcher)
exists is an idempotent operation.
|
String |
get(String path,
org.apache.zookeeper.Watcher watcher) |
List<String> |
getChildren(String path,
org.apache.zookeeper.Watcher watcher)
getChildren is an idempotent operation.
|
byte[] |
getData(String path,
boolean watch,
org.apache.zookeeper.data.Stat stat)
getData is an idemnpotent operation.
|
byte[] |
getData(String path,
org.apache.zookeeper.Watcher watcher,
org.apache.zookeeper.data.Stat stat)
getData is an idempotent operation.
|
long |
getSessionId() |
byte[] |
getSessionPasswd() |
org.apache.zookeeper.ZooKeeper.States |
getState() |
org.apache.zookeeper.ZooKeeper |
getZk() |
String |
getZkQuorum() |
org.apache.zookeeper.ZooKeeper |
getZooKeeper() |
static void |
main(String[] args) |
List<org.apache.zookeeper.OpResult> |
multi(Iterable<org.apache.zookeeper.Op> ops)
Run multiple operations in a transactional manner.
|
void |
process(org.apache.zookeeper.WatchedEvent event) |
byte[] |
removeMetaData(byte[] data) |
void |
resetZk() |
org.apache.zookeeper.data.Stat |
setData(String path,
byte[] data,
int version)
setData is NOT an idempotent operation.
|
void |
sync(String path,
org.apache.zookeeper.AsyncCallback.VoidCallback cb,
Object ctx) |
public ZkClient()
public ZkClient(int sessionTimeout, int maxRetries, int retryIntervalMillis)
public ZkClient(String zkhost, int zkport)
public String getZkQuorum()
public void connect() throws IOException, InterruptedException
IOException
InterruptedException
public void resetZk() throws IOException, InterruptedException
IOException
InterruptedException
public void close() throws InterruptedException
InterruptedException
public org.apache.zookeeper.ZooKeeper getZk()
public void process(org.apache.zookeeper.WatchedEvent event)
process
in interface org.apache.zookeeper.Watcher
public void create(String path, String value, boolean ephemeral) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public String get(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void delete(String path, int version) throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public org.apache.zookeeper.data.Stat exists(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public org.apache.zookeeper.data.Stat exists(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public List<String> getChildren(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public byte[] getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public byte[] getData(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public String create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, InterruptedException
NONSEQUENTIAL create is idempotent operation. Retry before throwing exceptions. But this function will not throw the NodeExist exception back to the application.
But SEQUENTIAL is NOT idempotent operation. It is necessary to add identifier to the path to verify, whether the previous one is successful or not.
org.apache.zookeeper.KeeperException
InterruptedException
public List<org.apache.zookeeper.OpResult> multi(Iterable<org.apache.zookeeper.Op> ops) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public byte[] removeMetaData(byte[] data)
public long getSessionId()
public org.apache.zookeeper.ZooKeeper.States getState()
public org.apache.zookeeper.ZooKeeper getZooKeeper()
public byte[] getSessionPasswd()
Copyright © 2016. All rights reserved.