Class ZooReader
- java.lang.Object
-
- org.apache.accumulo.core.fate.zookeeper.ZooReader
-
- Direct Known Subclasses:
ZooReaderWriter
public class ZooReader extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
ZooReader.ZKFunction<R>
protected static interface
ZooReader.ZKFunctionMutator<R>
-
Field Summary
Fields Modifier and Type Field Description protected String
keepers
protected static Retry.RetryFactory
RETRY_FACTORY
protected int
timeout
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZooReaderWriter
asWriter(String secret)
boolean
exists(String zPath)
boolean
exists(String zPath, org.apache.zookeeper.Watcher watcher)
List<String>
getChildren(String zPath)
List<String>
getChildren(String zPath, org.apache.zookeeper.Watcher watcher)
byte[]
getData(String zPath)
byte[]
getData(String zPath, org.apache.zookeeper.data.Stat stat)
byte[]
getData(String zPath, org.apache.zookeeper.Watcher watcher)
byte[]
getData(String zPath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat)
protected Retry.RetryFactory
getRetryFactory()
int
getSessionTimeout()
Returns the requested ZooKeeper client session timeout.org.apache.zookeeper.data.Stat
getStatus(String zPath)
org.apache.zookeeper.data.Stat
getStatus(String zPath, org.apache.zookeeper.Watcher watcher)
protected org.apache.zookeeper.ZooKeeper
getZooKeeper()
protected <R> R
retryLoop(ZooReader.ZKFunction<R> f)
This method executes the provided function, retrying several times for transient issues.protected <R> R
retryLoop(ZooReader.ZKFunction<R> zkf, Predicate<org.apache.zookeeper.KeeperException> alwaysRetryCondition)
This method executes the provided function, retrying several times for transient issues, and retrying indefinitely for special cases.protected <R> R
retryLoopMutator(ZooReader.ZKFunctionMutator<R> zkf, Predicate<org.apache.zookeeper.KeeperException> alwaysRetryCondition)
This method is a special case ofretryLoop(ZKFunction, Predicate)
, intended to handleZooReaderWriter.mutateExisting(String, ZooReaderWriter.Mutator)
's additional thrown exception type.void
sync(String path)
-
-
-
Field Detail
-
RETRY_FACTORY
protected static final Retry.RetryFactory RETRY_FACTORY
-
keepers
protected final String keepers
-
timeout
protected final int timeout
-
-
Constructor Detail
-
ZooReader
public ZooReader(String keepers, int timeout)
-
-
Method Detail
-
asWriter
public ZooReaderWriter asWriter(String secret)
-
getZooKeeper
protected org.apache.zookeeper.ZooKeeper getZooKeeper()
-
getRetryFactory
protected Retry.RetryFactory getRetryFactory()
-
getSessionTimeout
public int getSessionTimeout()
Returns the requested ZooKeeper client session timeout. The client may negotiate a different value and the actual negotiated value may change after a re-connect.- Returns:
- the timeout in milliseconds
-
getData
public byte[] getData(String zPath) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getData
public byte[] getData(String zPath, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getData
public byte[] getData(String zPath, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getData
public byte[] getData(String zPath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getStatus
public org.apache.zookeeper.data.Stat getStatus(String zPath) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getStatus
public org.apache.zookeeper.data.Stat getStatus(String zPath, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getChildren
public List<String> getChildren(String zPath) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getChildren
public List<String> getChildren(String zPath, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
exists
public boolean exists(String zPath) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
exists
public boolean exists(String zPath, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
sync
public void sync(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
retryLoop
protected <R> R retryLoop(ZooReader.ZKFunction<R> f) throws org.apache.zookeeper.KeeperException, InterruptedException
This method executes the provided function, retrying several times for transient issues.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
retryLoop
protected <R> R retryLoop(ZooReader.ZKFunction<R> zkf, Predicate<org.apache.zookeeper.KeeperException> alwaysRetryCondition) throws org.apache.zookeeper.KeeperException, InterruptedException
This method executes the provided function, retrying several times for transient issues, and retrying indefinitely for special cases. UseretryLoop(ZKFunction)
if there is no such special case.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
retryLoopMutator
protected <R> R retryLoopMutator(ZooReader.ZKFunctionMutator<R> zkf, Predicate<org.apache.zookeeper.KeeperException> alwaysRetryCondition) throws org.apache.zookeeper.KeeperException, InterruptedException, AcceptableThriftTableOperationException
This method is a special case ofretryLoop(ZKFunction, Predicate)
, intended to handleZooReaderWriter.mutateExisting(String, ZooReaderWriter.Mutator)
's additional thrown exception type. Other callers should useretryLoop(ZKFunction)
orretryLoop(ZKFunction, Predicate)
instead.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
AcceptableThriftTableOperationException
-
-