|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectml.shifu.guagua.coordinator.zk.GuaguaZooKeeper
public class GuaguaZooKeeper
ZooKeeper provides only atomic operations. GuaguaZooKeeper provides additional non-atomic operations that are useful. It also provides wrappers to deal with ConnectionLossException. All methods of this class should be thread-safe.
| 嵌套类摘要 | |
|---|---|
static interface |
GuaguaZooKeeper.Filter
Filter path out GuaguaZooKeeper.Filter.filter(String) return true. |
static class |
GuaguaZooKeeper.PathStat
Data structure for handling the output of createOrSet() |
| 构造方法摘要 | |
|---|---|
GuaguaZooKeeper(String connectString,
int sessionTimeout,
int maxRetryAttempts,
int retryWaitMsecs,
org.apache.zookeeper.Watcher watcher)
Constructor to connect to ZooKeeper, make progress |
|
| 方法摘要 | ||
|---|---|---|
void |
close()
Close this client object. |
|
String |
createExt(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode,
boolean recursive)
Provides a possibility of a creating a path consisting of more than one znode (not atomic). |
|
GuaguaZooKeeper.PathStat |
createOnceExt(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode,
boolean recursive)
Create a znode if there is no other znode there |
|
GuaguaZooKeeper.PathStat |
createOrSetExt(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode,
boolean recursive,
int version)
Create a znode. |
|
void |
deleteExt(String path,
int version,
boolean recursive)
Delete a path recursively. |
|
org.apache.zookeeper.data.Stat |
exists(String path,
boolean watch)
Return the stat of the node of the given path. |
|
org.apache.zookeeper.data.Stat |
exists(String path,
org.apache.zookeeper.Watcher watcher)
Return the stat of the node of the given path. |
|
List<String> |
getChildrenExt(String path,
boolean watch,
boolean sequenceSorted,
boolean fullPath)
Get the children of the path with extensions. |
|
List<String> |
getChildrenExt(String path,
boolean watch,
boolean sequenceSorted,
boolean fullPath,
GuaguaZooKeeper.Filter filter)
Get the children of the path with extensions. |
|
List<String> |
getChildrenExt(String path,
boolean watch,
boolean fullPath,
Comparator<String> childComparator)
Get the children of the path with extensions. |
|
byte[] |
getData(String path,
boolean watch,
org.apache.zookeeper.data.Stat stat)
Return the data and the stat of the node of the given path. |
|
byte[] |
getData(String path,
org.apache.zookeeper.Watcher watcher,
org.apache.zookeeper.data.Stat stat)
Return the data and the stat of the node of the given path. |
|
int |
getMaxRetryAttempts()
|
|
long |
getRetryWaitMsecs()
|
|
org.apache.zookeeper.ZooKeeper |
getZooKeeper()
|
|
protected void |
retryDelay(int attemptCount)
Performs a retry delay if this is not the first attempt |
|
protected
|
retryOperation(GuaguaZooKeeperOperation<T> operation)
Perform the given operation, retrying if the connection fails |
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public GuaguaZooKeeper(String connectString,
int sessionTimeout,
int maxRetryAttempts,
int retryWaitMsecs,
org.apache.zookeeper.Watcher watcher)
throws IOException
connectString - Comma separated host:port pairs, each corresponding to a zk server. e.g.
"127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002" If the optional chroot suffix is used the example would
look like: "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/app/a" where the client would be rooted at
"/app/a" and all paths would be relative to this root - ie getting/setting/etc... "/foo/bar" would
result in operations being run on "/app/a/foo/bar" (from the
server perspective).sessionTimeout - Session timeout in millisecondsmaxRetryAttempts - Max retry attempts during connection lossretryWaitMsecs - Msecs to wait when retrying due to connection losswatcher - A watcher object which will be notified of state changes, may also be notified for node events
IOException - In case of any io exception to connect to zookeeper server.| 方法详细信息 |
|---|
public String createExt(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode,
boolean recursive)
throws org.apache.zookeeper.KeeperException,
InterruptedException
path - path to createdata - data to set on the final znodeacl - acls on each znode createdcreateMode - only affects the final znoderecursive - if true, creates all ancestors
org.apache.zookeeper.KeeperException
InterruptedException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
NullPointerException - If path is null.
public GuaguaZooKeeper.PathStat createOrSetExt(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode,
boolean recursive,
int version)
throws org.apache.zookeeper.KeeperException,
InterruptedException
path - path to createdata - data to set on the final znodeacl - acls on each znode createdcreateMode - only affects the final znoderecursive - if true, creates all ancestorsversion - Version to set if setting
InterruptedException
org.apache.zookeeper.KeeperException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
public GuaguaZooKeeper.PathStat createOnceExt(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode,
boolean recursive)
throws org.apache.zookeeper.KeeperException,
InterruptedException
path - path to createdata - data to set on the final znodeacl - acls on each znode createdcreateMode - only affects the final znoderecursive - if true, creates all ancestors
InterruptedException
org.apache.zookeeper.KeeperException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
public void deleteExt(String path,
int version,
boolean recursive)
throws InterruptedException,
org.apache.zookeeper.KeeperException
path - path to remove (i.e. /tmp will remove /tmp/1 and /tmp/2)version - expected version (-1 for all)recursive - if true, remove all children, otherwise behave like remove()
InterruptedException
org.apache.zookeeper.KeeperException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
public org.apache.zookeeper.data.Stat exists(String path,
boolean watch)
throws org.apache.zookeeper.KeeperException,
InterruptedException
If the watch is true and the call is successful (no exception is thrown), a watch will be left on the node with the given path. The watch will be triggered by a successful operation that creates/delete the node or sets the data on the node.
path - the node pathwatch - whether need to watch this node
org.apache.zookeeper.KeeperException - If the server signals an error
InterruptedException - If the server transaction is interrupted.
public org.apache.zookeeper.data.Stat exists(String path,
org.apache.zookeeper.Watcher watcher)
throws org.apache.zookeeper.KeeperException,
InterruptedException
If the watch is non-null and the call is successful (no exception is thrown), a watch will be left on the node with the given path. The watch will be triggered by a successful operation that creates/delete the node or sets the data on the node.
path - the node pathwatcher - explicit watcher
org.apache.zookeeper.KeeperException - If the server signals an error
InterruptedException - If the server transaction is interrupted.
IllegalArgumentException - if an invalid path is specified
public byte[] getData(String path,
org.apache.zookeeper.Watcher watcher,
org.apache.zookeeper.data.Stat stat)
throws org.apache.zookeeper.KeeperException,
InterruptedException
If the watch is non-null and the call is successful (no exception is thrown), a watch will be left on the node with the given path. The watch will be triggered by a successful operation that sets data on the node, or deletes the node.
A KeeperException with error code KeeperException.NoNode will be thrown if no node with the given path exists.
path - the given pathwatcher - explicit watcherstat - the stat of the node
org.apache.zookeeper.KeeperException - If the server signals an error with a non-zero
error code
InterruptedException - If the server transaction is interrupted.
IllegalArgumentException - if an invalid path is specified
public byte[] getData(String path,
boolean watch,
org.apache.zookeeper.data.Stat stat)
throws org.apache.zookeeper.KeeperException,
InterruptedException
If the watch is true and the call is successful (no exception is thrown), a watch will be left on the node with the given path. The watch will be triggered by a successful operation that sets data on the node, or deletes the node.
A KeeperException with error code KeeperException.NoNode will be thrown if no node with the given path exists.
path - the given pathwatch - whether need to watch this nodestat - the stat of the node
org.apache.zookeeper.KeeperException - If the server signals an error with a non-zero error code
InterruptedException - If the server transaction is interrupted.
public List<String> getChildrenExt(String path,
boolean watch,
boolean fullPath,
Comparator<String> childComparator)
throws org.apache.zookeeper.KeeperException,
InterruptedException
childComparator number
Extension 2: Get the full path instead of relative path
path - path to znodewatch - set the watch?fullPath - if true, get the fully znode path backchildComparator - comparator to sort children.
InterruptedException
org.apache.zookeeper.KeeperException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
public List<String> getChildrenExt(String path,
boolean watch,
boolean sequenceSorted,
boolean fullPath)
throws org.apache.zookeeper.KeeperException,
InterruptedException
path - path to znodewatch - set the watch?sequenceSorted - sort by the sequence numberfullPath - if true, get the fully znode path back
InterruptedException
org.apache.zookeeper.KeeperException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
public List<String> getChildrenExt(String path,
boolean watch,
boolean sequenceSorted,
boolean fullPath,
GuaguaZooKeeper.Filter filter)
throws org.apache.zookeeper.KeeperException,
InterruptedException
path - path to znodewatch - set the watch?sequenceSorted - sort by the sequence numberfullPath - if true, get the fully znode path backfilter - filter some path out if not null.
InterruptedException
org.apache.zookeeper.KeeperException - Both KeeperException InterruptedException are thrown from ZooKeeper methods.
public void close()
throws InterruptedException
InterruptedException - in case of InterruptedException from ZooKeeper#close();
protected <T> T retryOperation(GuaguaZooKeeperOperation<T> operation)
throws org.apache.zookeeper.KeeperException,
InterruptedException
org.apache.zookeeper.KeeperException
InterruptedExceptionprotected void retryDelay(int attemptCount)
attemptCount - the number of the attempts performed so farpublic org.apache.zookeeper.ZooKeeper getZooKeeper()
public int getMaxRetryAttempts()
public long getRetryWaitMsecs()
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||