Package org.apache.curator.framework
Interface CuratorFramework
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Subinterfaces:
WatcherRemoveCuratorFramework
- All Known Implementing Classes:
CuratorFrameworkImpl
public interface CuratorFramework extends java.io.CloseableZookeeper framework-style client
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidblockUntilConnected()Block until a connection to ZooKeeper is available.booleanblockUntilConnected(int maxWaitTime, java.util.concurrent.TimeUnit units)Block until a connection to ZooKeeper is available or the maxWaitTime has been exceededExistsBuildercheckExists()Start an exists buildervoidclearWatcherReferences(org.apache.zookeeper.Watcher watcher)Deprecated.As of ZooKeeper 3.5 Curators recipes will handle removing watcher references when they are no longer used.voidclose()Stop the clientCreateBuildercreate()Start a create buildervoidcreateContainers(java.lang.String path)Create all nodes in the specified path as containers if they don't already existDeleteBuilderdelete()Start a delete builderGetACLBuildergetACL()Start a get ACL builderGetChildrenBuildergetChildren()Start a get children builderGetConfigBuildergetConfig()Start a getConfig builderConnectionStateErrorPolicygetConnectionStateErrorPolicy()Return the configured error policyListenable<ConnectionStateListener>getConnectionStateListenable()Returns the listenable interface for the Connect StateListenable<CuratorListener>getCuratorListenable()Returns the listenable interface for eventsorg.apache.zookeeper.server.quorum.flexible.QuorumVerifiergetCurrentConfig()Current maintains a cached view of the Zookeeper quorum config.GetDataBuildergetData()Start a get data builderjava.lang.StringgetNamespace()Return the current namespace or "" if noneSchemaSetgetSchemaSet()Return this instance's schema setCuratorFrameworkStategetState()Returns the state of this instanceListenable<UnhandledErrorListener>getUnhandledErrorListenable()Returns the listenable interface for unhandled errorsorg.apache.curator.CuratorZookeeperClientgetZookeeperClient()Return the managed zookeeper clientCuratorTransactioninTransaction()Deprecated.usetransaction()insteadbooleanisStarted()Deprecated.usegetState()insteadbooleanisZk34CompatibilityMode()Return true if this instance is running in ZK 3.4.x compatibility modeorg.apache.curator.utils.EnsurePathnewNamespaceAwareEnsurePath(java.lang.String path)Deprecated.WatcherRemoveCuratorFrameworknewWatcherRemoveCuratorFramework()Returns a facade of the current instance that tracks watchers created and allows a one-shot removal of all watchers viaWatcherRemoveCuratorFramework.removeWatchers()CuratorFrameworknonNamespaceView()Deprecated.Since 2.9.0 - useusingNamespace(java.lang.String)passingnulldefault java.util.concurrent.CompletableFuture<java.lang.Void>postSafeNotify(java.lang.Object monitorHolder)Calls#notifyAll()on the given object after first synchronizing on it.ReconfigBuilderreconfig()Start a reconfig builderjava.util.concurrent.CompletableFuture<java.lang.Void>runSafe(java.lang.Runnable runnable)Curator (and user) recipes can use this to run notifyAll and other blocking calls that might normally block ZooKeeper's event thread.SetACLBuildersetACL()Start a set ACL builderSetDataBuildersetData()Start a set data buildervoidstart()Start the client.SyncBuildersync()Start a sync builder.voidsync(java.lang.String path, java.lang.Object backgroundContextObject)Deprecated.usesync()insteadCuratorMultiTransactiontransaction()Start a transaction builderTransactionOptransactionOp()Allocate an operation that can be used withtransaction().CuratorFrameworkusingNamespace(java.lang.String newNamespace)Returns a facade of the current instance that uses the specified namespace or no namespace ifnewNamespaceisnull.RemoveWatchesBuilderwatches()Start a remove watches builder.
-
-
-
Method Detail
-
start
void start()
Start the client. Most mutator methods will not work until the client is started
-
close
void close()
Stop the client- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
getState
CuratorFrameworkState getState()
Returns the state of this instance- Returns:
- state
-
isStarted
@Deprecated boolean isStarted()
Deprecated.usegetState()insteadReturn true if the client is started, not closed, etc.- Returns:
- true/false
-
create
CreateBuilder create()
Start a create builder- Returns:
- builder object
-
delete
DeleteBuilder delete()
Start a delete builder- Returns:
- builder object
-
checkExists
ExistsBuilder checkExists()
Start an exists builderThe builder will return a Stat object as if org.apache.zookeeper.ZooKeeper.exists() were called. Thus, a null means that it does not exist and an actual Stat object means it does exist.
- Returns:
- builder object
-
getData
GetDataBuilder getData()
Start a get data builder- Returns:
- builder object
-
setData
SetDataBuilder setData()
Start a set data builder- Returns:
- builder object
-
getChildren
GetChildrenBuilder getChildren()
Start a get children builder- Returns:
- builder object
-
getACL
GetACLBuilder getACL()
Start a get ACL builder- Returns:
- builder object
-
setACL
SetACLBuilder setACL()
Start a set ACL builder- Returns:
- builder object
-
reconfig
ReconfigBuilder reconfig()
Start a reconfig builder- Returns:
- builder object
-
getConfig
GetConfigBuilder getConfig()
Start a getConfig builder- Returns:
- builder object
-
inTransaction
CuratorTransaction inTransaction()
Deprecated.usetransaction()insteadStart a transaction builder- Returns:
- builder object
-
transaction
CuratorMultiTransaction transaction()
Start a transaction builder- Returns:
- builder object
-
transactionOp
TransactionOp transactionOp()
Allocate an operation that can be used withtransaction(). NOTE:CuratorOpinstances created by this builder are reusable.- Returns:
- operation builder
-
sync
@Deprecated void sync(java.lang.String path, java.lang.Object backgroundContextObject)Deprecated.usesync()insteadPerform a sync on the given path - syncs are always in the background- Parameters:
path- the pathbackgroundContextObject- optional context
-
createContainers
void createContainers(java.lang.String path) throws java.lang.ExceptionCreate all nodes in the specified path as containers if they don't already exist- Parameters:
path- path to create- Throws:
java.lang.Exception- errors
-
sync
SyncBuilder sync()
Start a sync builder. Note: sync is ALWAYS in the background even if you don't use one of the background() methods- Returns:
- builder object
-
watches
RemoveWatchesBuilder watches()
Start a remove watches builder.- Returns:
- builder object
-
getConnectionStateListenable
Listenable<ConnectionStateListener> getConnectionStateListenable()
Returns the listenable interface for the Connect State- Returns:
- listenable
-
getCuratorListenable
Listenable<CuratorListener> getCuratorListenable()
Returns the listenable interface for events- Returns:
- listenable
-
getUnhandledErrorListenable
Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
Returns the listenable interface for unhandled errors- Returns:
- listenable
-
nonNamespaceView
@Deprecated CuratorFramework nonNamespaceView()
Deprecated.Since 2.9.0 - useusingNamespace(java.lang.String)passingnullReturns a facade of the current instance that does _not_ automatically pre-pend the namespace to all paths- Returns:
- facade
-
usingNamespace
CuratorFramework usingNamespace(java.lang.String newNamespace)
Returns a facade of the current instance that uses the specified namespace or no namespace ifnewNamespaceisnull.- Parameters:
newNamespace- the new namespace or null for none- Returns:
- facade
-
getNamespace
java.lang.String getNamespace()
Return the current namespace or "" if none- Returns:
- namespace
-
getZookeeperClient
org.apache.curator.CuratorZookeeperClient getZookeeperClient()
Return the managed zookeeper client- Returns:
- client
-
newNamespaceAwareEnsurePath
@Deprecated org.apache.curator.utils.EnsurePath newNamespaceAwareEnsurePath(java.lang.String path)
Deprecated.Allocates an ensure path instance that is namespace aware- Parameters:
path- path to ensure- Returns:
- new EnsurePath instance
-
clearWatcherReferences
@Deprecated void clearWatcherReferences(org.apache.zookeeper.Watcher watcher)
Deprecated.As of ZooKeeper 3.5 Curators recipes will handle removing watcher references when they are no longer used. If you write your own recipe, follow the example of Curator recipes and usenewWatcherRemoveCuratorFramework()callingWatcherRemoveCuratorFramework.removeWatchers()when closing your instance.Curator can hold internal references to watchers that may inhibit garbage collection. Call this method on watchers you are no longer interested in.- Parameters:
watcher- the watcher
-
blockUntilConnected
boolean blockUntilConnected(int maxWaitTime, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedExceptionBlock until a connection to ZooKeeper is available or the maxWaitTime has been exceeded- Parameters:
maxWaitTime- The maximum wait time. Specify a value <= 0 to wait indefinitelyunits- The time units for the maximum wait time.- Returns:
- True if connection has been established, false otherwise.
- Throws:
java.lang.InterruptedException- If interrupted while waiting
-
blockUntilConnected
void blockUntilConnected() throws java.lang.InterruptedExceptionBlock until a connection to ZooKeeper is available. This method will not return until a connection is available or it is interrupted, in which case an InterruptedException will be thrown- Throws:
java.lang.InterruptedException- If interrupted while waiting
-
newWatcherRemoveCuratorFramework
WatcherRemoveCuratorFramework newWatcherRemoveCuratorFramework()
Returns a facade of the current instance that tracks watchers created and allows a one-shot removal of all watchers viaWatcherRemoveCuratorFramework.removeWatchers()- Returns:
- facade
-
getConnectionStateErrorPolicy
ConnectionStateErrorPolicy getConnectionStateErrorPolicy()
Return the configured error policy- Returns:
- error policy
-
getCurrentConfig
org.apache.zookeeper.server.quorum.flexible.QuorumVerifier getCurrentConfig()
Current maintains a cached view of the Zookeeper quorum config.- Returns:
- the current config
-
getSchemaSet
SchemaSet getSchemaSet()
Return this instance's schema set- Returns:
- schema set
-
isZk34CompatibilityMode
boolean isZk34CompatibilityMode()
Return true if this instance is running in ZK 3.4.x compatibility mode- Returns:
- true/false
-
postSafeNotify
default java.util.concurrent.CompletableFuture<java.lang.Void> postSafeNotify(java.lang.Object monitorHolder)
Calls#notifyAll()on the given object after first synchronizing on it. This is done from therunSafe(Runnable)thread.- Parameters:
monitorHolder- object to sync on and notify- Returns:
- a CompletableFuture that can be used to monitor when the call is complete
- Since:
- 4.1.0
-
runSafe
java.util.concurrent.CompletableFuture<java.lang.Void> runSafe(java.lang.Runnable runnable)
Curator (and user) recipes can use this to run notifyAll and other blocking calls that might normally block ZooKeeper's event thread.- Parameters:
runnable- proc to call from a safe internal thread- Returns:
- a CompletableFuture that can be used to monitor when the call is complete
- Since:
- 4.1.0
-
-