java.io.Closeable, java.lang.AutoCloseablepublic class CuratorZookeeperClient
extends java.lang.Object
implements java.io.Closeable
| Constructor | Description |
|---|---|
CuratorZookeeperClient(java.lang.String connectString,
int sessionTimeoutMs,
int connectionTimeoutMs,
org.apache.zookeeper.Watcher watcher,
RetryPolicy retryPolicy) |
|
CuratorZookeeperClient(EnsembleProvider ensembleProvider,
int sessionTimeoutMs,
int connectionTimeoutMs,
org.apache.zookeeper.Watcher watcher,
RetryPolicy retryPolicy) |
|
CuratorZookeeperClient(ZookeeperFactory zookeeperFactory,
EnsembleProvider ensembleProvider,
int sessionTimeoutMs,
int connectionTimeoutMs,
org.apache.zookeeper.Watcher watcher,
RetryPolicy retryPolicy,
boolean canBeReadOnly) |
|
CuratorZookeeperClient(ZookeeperFactory zookeeperFactory,
EnsembleProvider ensembleProvider,
int sessionTimeoutMs,
int connectionTimeoutMs,
org.apache.zookeeper.Watcher watcher,
RetryPolicy retryPolicy,
boolean canBeReadOnly,
ConnectionHandlingPolicy connectionHandlingPolicy) |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
blockUntilConnectedOrTimedOut() |
This method blocks until the connection to ZK succeeds.
|
void |
close() |
Close the client
|
ConnectionHandlingPolicy |
getConnectionHandlingPolicy() |
Return the configured connection handling policy
|
int |
getConnectionTimeoutMs() |
Return the configured connection timeout
|
java.lang.String |
getCurrentConnectionString() |
Returns the current known connection string - not guaranteed to be correct
value at any point in the future.
|
long |
getInstanceIndex() |
Every time a new
ZooKeeper instance is allocated, the "instance index"
is incremented. |
int |
getLastNegotiatedSessionTimeoutMs() |
Return the most recent value of
ZooKeeper.getSessionTimeout() or 0 |
RetryPolicy |
getRetryPolicy() |
Return the current retry policy
|
TracerDriver |
getTracerDriver() |
Return the current tracing driver
|
org.apache.zookeeper.ZooKeeper |
getZooKeeper() |
Return the managed ZK instance.
|
void |
internalBlockUntilConnectedOrTimedOut() |
For internal use only
|
boolean |
isConnected() |
Returns true if the client is current connected
|
RetryLoop |
newRetryLoop() |
Return a new retry loop.
|
SessionFailRetryLoop |
newSessionFailRetryLoop(SessionFailRetryLoop.Mode mode) |
Return a new "session fail" retry loop.
|
void |
reset() |
For internal use only - reset the internally managed ZK handle
|
void |
setRetryPolicy(RetryPolicy policy) |
Change the retry policy
|
void |
setTracerDriver(TracerDriver tracer) |
Change the tracing driver
|
void |
start() |
Must be called after construction
|
OperationTrace |
startAdvancedTracer(java.lang.String name) |
Start a new advanced tracer with more metrics being recorded
|
TimeTrace |
startTracer(java.lang.String name) |
Start a new tracer
|
public CuratorZookeeperClient(java.lang.String connectString,
int sessionTimeoutMs,
int connectionTimeoutMs,
org.apache.zookeeper.Watcher watcher,
RetryPolicy retryPolicy)
connectString - list of servers to connect tosessionTimeoutMs - session timeoutconnectionTimeoutMs - connection timeoutwatcher - default watcher or nullretryPolicy - the retry policy to usepublic CuratorZookeeperClient(EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, org.apache.zookeeper.Watcher watcher, RetryPolicy retryPolicy)
ensembleProvider - the ensemble providersessionTimeoutMs - session timeoutconnectionTimeoutMs - connection timeoutwatcher - default watcher or nullretryPolicy - the retry policy to usepublic CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, org.apache.zookeeper.Watcher watcher, RetryPolicy retryPolicy, boolean canBeReadOnly)
zookeeperFactory - factory for creating ZooKeeper instancesensembleProvider - the ensemble providersessionTimeoutMs - session timeoutconnectionTimeoutMs - connection timeoutwatcher - default watcher or nullretryPolicy - the retry policy to usecanBeReadOnly - if true, allow ZooKeeper client to enter
read only mode in case of a network partition. See
ZooKeeper(String, int, Watcher, long, byte[], boolean)
for detailspublic CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, org.apache.zookeeper.Watcher watcher, RetryPolicy retryPolicy, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy)
zookeeperFactory - factory for creating ZooKeeper instancesensembleProvider - the ensemble providersessionTimeoutMs - session timeoutconnectionTimeoutMs - connection timeoutwatcher - default watcher or nullretryPolicy - the retry policy to usecanBeReadOnly - if true, allow ZooKeeper client to enter
read only mode in case of a network partition. See
ZooKeeper(String, int, Watcher, long, byte[], boolean)
for detailsconnectionHandlingPolicy - connection handling policy - use one of the pre-defined policies or write your ownpublic org.apache.zookeeper.ZooKeeper getZooKeeper()
throws java.lang.Exception
java.lang.Exception - if the connection timeout has elapsed or an exception occurs in a background processpublic RetryLoop newRetryLoop()
public SessionFailRetryLoop newSessionFailRetryLoop(SessionFailRetryLoop.Mode mode)
SessionFailRetryLoop for details
on when to use it.mode - failure modepublic boolean isConnected()
public boolean blockUntilConnectedOrTimedOut()
throws java.lang.InterruptedException
java.lang.InterruptedException - interrupted while waitingpublic void start()
throws java.lang.Exception
java.io.IOException - errorsjava.lang.Exceptionpublic void close()
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablepublic void setRetryPolicy(RetryPolicy policy)
policy - new policypublic RetryPolicy getRetryPolicy()
public TimeTrace startTracer(java.lang.String name)
name - name of the eventTimeTrace.commit() must be called)public OperationTrace startAdvancedTracer(java.lang.String name)
name - name of the eventOperationTrace.commit() must be called)public TracerDriver getTracerDriver()
public void setTracerDriver(TracerDriver tracer)
tracer - new tracing driverpublic java.lang.String getCurrentConnectionString()
public int getConnectionTimeoutMs()
public void reset()
throws java.lang.Exception
java.lang.Exception - errorspublic long getInstanceIndex()
ZooKeeper instance is allocated, the "instance index"
is incremented.public ConnectionHandlingPolicy getConnectionHandlingPolicy()
public int getLastNegotiatedSessionTimeoutMs()
ZooKeeper.getSessionTimeout() or 0public void internalBlockUntilConnectedOrTimedOut()
throws java.lang.InterruptedException
java.lang.InterruptedException - interruptionsCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.