Class CuratorFrameworkImpl
- java.lang.Object
-
- org.apache.curator.framework.imps.CuratorFrameworkImpl
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,CuratorFramework
public class CuratorFrameworkImpl extends java.lang.Object implements CuratorFramework
-
-
Field Summary
Fields Modifier and Type Field Description UnhandledErrorListenerdebugUnhandledErrorListener
-
Constructor Summary
Constructors Modifier Constructor Description CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)protectedCuratorFrameworkImpl(CuratorFrameworkImpl parent)
-
Method Summary
All Methods Instance Methods Concrete 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)Curator can hold internal references to watchers that may inhibit garbage collection.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 clientprotected voidinternalSync(CuratorFrameworkImpl impl, java.lang.String path, java.lang.Object context)CuratorTransactioninTransaction()Start a transaction builderbooleanisStarted()Deprecated.org.apache.curator.utils.EnsurePathnewNamespaceAwareEnsurePath(java.lang.String path)Allocates an ensure path instance that is namespace awareWatcherRemoveCuratorFrameworknewWatcherRemoveCuratorFramework()Returns a facade of the current instance that tracks watchers created and allows a one-shot removal of all watchers viaWatcherRemoveCuratorFramework.removeWatchers()CuratorFrameworknonNamespaceView()Deprecated.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 context)Perform a sync on the given path - syncs are always in the backgroundCuratorMultiTransactiontransaction()Start a transaction builderTransactionOptransactionOp()Allocate an operation that can be used withCuratorFramework.transaction().CuratorFrameworkusingNamespace(java.lang.String newNamespace)Returns a facade of the current instance that uses the specified namespace or no namespace ifnewNamespaceisnull.WatchesBuilderwatchers()Start a watch builder.RemoveWatchesBuilderwatches()Start a remove watches builder.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.curator.framework.CuratorFramework
postSafeNotify
-
-
-
-
Field Detail
-
debugUnhandledErrorListener
public volatile UnhandledErrorListener debugUnhandledErrorListener
-
-
Constructor Detail
-
CuratorFrameworkImpl
public CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)
-
CuratorFrameworkImpl
protected CuratorFrameworkImpl(CuratorFrameworkImpl parent)
-
-
Method Detail
-
runSafe
public java.util.concurrent.CompletableFuture<java.lang.Void> runSafe(java.lang.Runnable runnable)
Description copied from interface:CuratorFrameworkCurator (and user) recipes can use this to run notifyAll and other blocking calls that might normally block ZooKeeper's event thread.- Specified by:
runSafein interfaceCuratorFramework- Parameters:
runnable- proc to call from a safe internal thread- Returns:
- a CompletableFuture that can be used to monitor when the call is complete
-
newWatcherRemoveCuratorFramework
public WatcherRemoveCuratorFramework newWatcherRemoveCuratorFramework()
Description copied from interface:CuratorFrameworkReturns a facade of the current instance that tracks watchers created and allows a one-shot removal of all watchers viaWatcherRemoveCuratorFramework.removeWatchers()- Specified by:
newWatcherRemoveCuratorFrameworkin interfaceCuratorFramework- Returns:
- facade
-
getCurrentConfig
public org.apache.zookeeper.server.quorum.flexible.QuorumVerifier getCurrentConfig()
Description copied from interface:CuratorFrameworkCurrent maintains a cached view of the Zookeeper quorum config.- Specified by:
getCurrentConfigin interfaceCuratorFramework- Returns:
- the current config
-
createContainers
public void createContainers(java.lang.String path) throws java.lang.ExceptionDescription copied from interface:CuratorFrameworkCreate all nodes in the specified path as containers if they don't already exist- Specified by:
createContainersin interfaceCuratorFramework- Parameters:
path- path to create- Throws:
java.lang.Exception- errors
-
clearWatcherReferences
public void clearWatcherReferences(org.apache.zookeeper.Watcher watcher)
Description copied from interface:CuratorFrameworkCurator can hold internal references to watchers that may inhibit garbage collection. Call this method on watchers you are no longer interested in.- Specified by:
clearWatcherReferencesin interfaceCuratorFramework- Parameters:
watcher- the watcher
-
getState
public CuratorFrameworkState getState()
Description copied from interface:CuratorFrameworkReturns the state of this instance- Specified by:
getStatein interfaceCuratorFramework- Returns:
- state
-
isStarted
@Deprecated public boolean isStarted()
Deprecated.Description copied from interface:CuratorFrameworkReturn true if the client is started, not closed, etc.- Specified by:
isStartedin interfaceCuratorFramework- Returns:
- true/false
-
blockUntilConnected
public boolean blockUntilConnected(int maxWaitTime, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedExceptionDescription copied from interface:CuratorFrameworkBlock until a connection to ZooKeeper is available or the maxWaitTime has been exceeded- Specified by:
blockUntilConnectedin interfaceCuratorFramework- 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
public void blockUntilConnected() throws java.lang.InterruptedExceptionDescription copied from interface:CuratorFrameworkBlock 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- Specified by:
blockUntilConnectedin interfaceCuratorFramework- Throws:
java.lang.InterruptedException- If interrupted while waiting
-
getConnectionStateErrorPolicy
public ConnectionStateErrorPolicy getConnectionStateErrorPolicy()
Description copied from interface:CuratorFrameworkReturn the configured error policy- Specified by:
getConnectionStateErrorPolicyin interfaceCuratorFramework- Returns:
- error policy
-
start
public void start()
Description copied from interface:CuratorFrameworkStart the client. Most mutator methods will not work until the client is started- Specified by:
startin interfaceCuratorFramework
-
close
public void close()
Description copied from interface:CuratorFrameworkStop the client- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceCuratorFramework
-
nonNamespaceView
@Deprecated public CuratorFramework nonNamespaceView()
Deprecated.Description copied from interface:CuratorFrameworkReturns a facade of the current instance that does _not_ automatically pre-pend the namespace to all paths- Specified by:
nonNamespaceViewin interfaceCuratorFramework- Returns:
- facade
-
getNamespace
public java.lang.String getNamespace()
Description copied from interface:CuratorFrameworkReturn the current namespace or "" if none- Specified by:
getNamespacein interfaceCuratorFramework- Returns:
- namespace
-
usingNamespace
public CuratorFramework usingNamespace(java.lang.String newNamespace)
Description copied from interface:CuratorFrameworkReturns a facade of the current instance that uses the specified namespace or no namespace ifnewNamespaceisnull.- Specified by:
usingNamespacein interfaceCuratorFramework- Parameters:
newNamespace- the new namespace or null for none- Returns:
- facade
-
create
public CreateBuilder create()
Description copied from interface:CuratorFrameworkStart a create builder- Specified by:
createin interfaceCuratorFramework- Returns:
- builder object
-
delete
public DeleteBuilder delete()
Description copied from interface:CuratorFrameworkStart a delete builder- Specified by:
deletein interfaceCuratorFramework- Returns:
- builder object
-
checkExists
public ExistsBuilder checkExists()
Description copied from interface:CuratorFrameworkStart 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.
- Specified by:
checkExistsin interfaceCuratorFramework- Returns:
- builder object
-
getData
public GetDataBuilder getData()
Description copied from interface:CuratorFrameworkStart a get data builder- Specified by:
getDatain interfaceCuratorFramework- Returns:
- builder object
-
setData
public SetDataBuilder setData()
Description copied from interface:CuratorFrameworkStart a set data builder- Specified by:
setDatain interfaceCuratorFramework- Returns:
- builder object
-
getChildren
public GetChildrenBuilder getChildren()
Description copied from interface:CuratorFrameworkStart a get children builder- Specified by:
getChildrenin interfaceCuratorFramework- Returns:
- builder object
-
getACL
public GetACLBuilder getACL()
Description copied from interface:CuratorFrameworkStart a get ACL builder- Specified by:
getACLin interfaceCuratorFramework- Returns:
- builder object
-
setACL
public SetACLBuilder setACL()
Description copied from interface:CuratorFrameworkStart a set ACL builder- Specified by:
setACLin interfaceCuratorFramework- Returns:
- builder object
-
reconfig
public ReconfigBuilder reconfig()
Description copied from interface:CuratorFrameworkStart a reconfig builder- Specified by:
reconfigin interfaceCuratorFramework- Returns:
- builder object
-
getConfig
public GetConfigBuilder getConfig()
Description copied from interface:CuratorFrameworkStart a getConfig builder- Specified by:
getConfigin interfaceCuratorFramework- Returns:
- builder object
-
inTransaction
public CuratorTransaction inTransaction()
Description copied from interface:CuratorFrameworkStart a transaction builder- Specified by:
inTransactionin interfaceCuratorFramework- Returns:
- builder object
-
transaction
public CuratorMultiTransaction transaction()
Description copied from interface:CuratorFrameworkStart a transaction builder- Specified by:
transactionin interfaceCuratorFramework- Returns:
- builder object
-
transactionOp
public TransactionOp transactionOp()
Description copied from interface:CuratorFrameworkAllocate an operation that can be used withCuratorFramework.transaction(). NOTE:CuratorOpinstances created by this builder are reusable.- Specified by:
transactionOpin interfaceCuratorFramework- Returns:
- operation builder
-
getConnectionStateListenable
public Listenable<ConnectionStateListener> getConnectionStateListenable()
Description copied from interface:CuratorFrameworkReturns the listenable interface for the Connect State- Specified by:
getConnectionStateListenablein interfaceCuratorFramework- Returns:
- listenable
-
getCuratorListenable
public Listenable<CuratorListener> getCuratorListenable()
Description copied from interface:CuratorFrameworkReturns the listenable interface for events- Specified by:
getCuratorListenablein interfaceCuratorFramework- Returns:
- listenable
-
getUnhandledErrorListenable
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
Description copied from interface:CuratorFrameworkReturns the listenable interface for unhandled errors- Specified by:
getUnhandledErrorListenablein interfaceCuratorFramework- Returns:
- listenable
-
sync
public void sync(java.lang.String path, java.lang.Object context)Description copied from interface:CuratorFrameworkPerform a sync on the given path - syncs are always in the background- Specified by:
syncin interfaceCuratorFramework- Parameters:
path- the pathcontext- optional context
-
sync
public SyncBuilder sync()
Description copied from interface:CuratorFrameworkStart a sync builder. Note: sync is ALWAYS in the background even if you don't use one of the background() methods- Specified by:
syncin interfaceCuratorFramework- Returns:
- builder object
-
watches
public RemoveWatchesBuilder watches()
Description copied from interface:CuratorFrameworkStart a remove watches builder.- Specified by:
watchesin interfaceCuratorFramework- Returns:
- builder object
-
watchers
public WatchesBuilder watchers()
Description copied from interface:CuratorFrameworkStart a watch builder. Supported only when ZooKeeper JAR of version 3.6 or above is used, throwsIllegalStateExceptionfor ZooKeeper JAR 3.5 or below- Specified by:
watchersin interfaceCuratorFramework- Returns:
- builder object
-
internalSync
protected void internalSync(CuratorFrameworkImpl impl, java.lang.String path, java.lang.Object context)
-
getZookeeperClient
public org.apache.curator.CuratorZookeeperClient getZookeeperClient()
Description copied from interface:CuratorFrameworkReturn the managed zookeeper client- Specified by:
getZookeeperClientin interfaceCuratorFramework- Returns:
- client
-
newNamespaceAwareEnsurePath
public org.apache.curator.utils.EnsurePath newNamespaceAwareEnsurePath(java.lang.String path)
Description copied from interface:CuratorFrameworkAllocates an ensure path instance that is namespace aware- Specified by:
newNamespaceAwareEnsurePathin interfaceCuratorFramework- Parameters:
path- path to ensure- Returns:
- new EnsurePath instance
-
getSchemaSet
public SchemaSet getSchemaSet()
Description copied from interface:CuratorFrameworkReturn this instance's schema set- Specified by:
getSchemaSetin interfaceCuratorFramework- Returns:
- schema set
-
-