Class ModeledFrameworkImpl<T>
- java.lang.Object
-
- org.apache.curator.x.async.modeled.details.ModeledFrameworkImpl<T>
-
- All Implemented Interfaces:
ModeledFramework<T>
public class ModeledFrameworkImpl<T> extends java.lang.Object implements ModeledFramework<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> ModeledFrameworkImpl<T>build(AsyncCuratorFramework client, ModelSpec<T> model, WatchMode watchMode, java.util.function.UnaryOperator<org.apache.zookeeper.WatchedEvent> watcherFilter, org.apache.curator.framework.api.UnhandledErrorListener unhandledErrorListener, java.util.function.UnaryOperator<org.apache.curator.framework.api.CuratorEvent> resultFilter, java.util.Set<ModeledOptions> modeledOptions)CachedModeledFramework<T>cached()Use an internally created cache as a front for this modeled instance.CachedModeledFramework<T>cached(java.util.concurrent.ExecutorService executor)Same asModeledFramework.cached()but allows for providing an executor serviceAsyncStage<org.apache.zookeeper.data.Stat>checkExists()Check to see if the ZNode at this instance's path existsorg.apache.curator.framework.api.transaction.CuratorOpcheckExistsOp()Check exists operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.org.apache.curator.framework.api.transaction.CuratorOpcheckExistsOp(int version)Check exists operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.ModeledFramework<T>child(java.lang.Object child)Return a new Modeled Curator instance with all the same options but applying to the given child node of this Modeled Curator's path.AsyncStage<java.util.List<ZPath>>children()Return the child paths of this instance's path (in no particular order)AsyncStage<java.util.List<ZNode<T>>>childrenAsZNodes()Return the child paths of this instance's path (in no particular order) and deserialize into a models.org.apache.curator.framework.api.transaction.CuratorOpcreateOp(T model)Create operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.AsyncStage<java.lang.Void>delete()Delete the ZNode at this instance's path passing -1 for the delete versionAsyncStage<java.lang.Void>delete(int version)Delete the ZNode at this instance's path passing the given delete versionorg.apache.curator.framework.api.transaction.CuratorOpdeleteOp()Delete operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.org.apache.curator.framework.api.transaction.CuratorOpdeleteOp(int version)Delete operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.AsyncStage<java.util.List<org.apache.curator.framework.api.transaction.CuratorTransactionResult>>inTransaction(java.util.List<org.apache.curator.framework.api.transaction.CuratorOp> operations)Invoke ZooKeeper to commit the given operations as a single transaction.static booleanisCompressed(java.util.Set<CreateOption> createOptions)ModelSpec<T>modelSpec()Return the model being usedModeledFramework<T>parent()Return a new Modeled Curator instance with all the same options but applying to the parent node of this Modeled Curator's path.AsyncStage<T>read()Read the ZNode at this instance's path and deserialize into a modelAsyncStage<T>read(org.apache.zookeeper.data.Stat storingStatIn)Read the ZNode at this instance's path and deserialize into a modelAsyncStage<ZNode<T>>readAsZNode()Read the ZNode at this instance's path and deserialize into a modelAsyncStage<java.lang.String>set(T item)Create (or update depending on build options) a ZNode at this instance's path with a serialized version of the given modelAsyncStage<java.lang.String>set(T item, int version)Create (or update depending on build options) a ZNode at this instance's path with a serialized version of the given modelAsyncStage<java.lang.String>set(T item, org.apache.zookeeper.data.Stat storingStatIn)Create (or update depending on build options) a ZNode at this instance's path with a serialized form of the given modelAsyncStage<java.lang.String>set(T item, org.apache.zookeeper.data.Stat storingStatIn, int version)Create (or update depending on build options) a ZNode at this instance's path with a serialized form of the given modelAsyncCuratorFrameworkunwrap()Returns the client that was originally passed toModeledFramework.wrap(org.apache.curator.x.async.AsyncCuratorFramework, ModelSpec)or the builder.AsyncStage<org.apache.zookeeper.data.Stat>update(T item)Update the ZNode at this instance's path with a serialized form of the given model passing "-1" for the update versionAsyncStage<org.apache.zookeeper.data.Stat>update(T item, int version)Update the ZNode at this instance's path with a serialized form of the given model passing the given update versionorg.apache.curator.framework.api.transaction.CuratorOpupdateOp(T model)Update operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.org.apache.curator.framework.api.transaction.CuratorOpupdateOp(T model, int version)Create operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.VersionedModeledFramework<T>versioned()Return mutator APIs that work withVersionedcontainersModeledFramework<T>withPath(ZPath path)Return a Modeled Curator instance with all the same options but using the given path.
-
-
-
Method Detail
-
build
public static <T> ModeledFrameworkImpl<T> build(AsyncCuratorFramework client, ModelSpec<T> model, WatchMode watchMode, java.util.function.UnaryOperator<org.apache.zookeeper.WatchedEvent> watcherFilter, org.apache.curator.framework.api.UnhandledErrorListener unhandledErrorListener, java.util.function.UnaryOperator<org.apache.curator.framework.api.CuratorEvent> resultFilter, java.util.Set<ModeledOptions> modeledOptions)
-
cached
public CachedModeledFramework<T> cached()
Description copied from interface:ModeledFrameworkUse an internally created cache as a front for this modeled instance. All read APIs use the internal cache. i.e. read calls always use the cache instead of making direct queries. Note: you must call
CachedModeledFramework.start()andCachedModeledFramework.close()to start/stopNote: the root node (the main path of the model) is not cached. i.e. only nodes below the root are cached.
Note: this method internally allocates an Executor for the cache and read methods. Use
ModeledFramework.cached(java.util.concurrent.ExecutorService)if you'd like to provide your own executor service.- Specified by:
cachedin interfaceModeledFramework<T>- Returns:
- wrapped instance
-
cached
public CachedModeledFramework<T> cached(java.util.concurrent.ExecutorService executor)
Description copied from interface:ModeledFrameworkSame asModeledFramework.cached()but allows for providing an executor service- Specified by:
cachedin interfaceModeledFramework<T>- Parameters:
executor- thread pool to use for the cache and for read operations- Returns:
- wrapped instance
-
versioned
public VersionedModeledFramework<T> versioned()
Description copied from interface:ModeledFrameworkReturn mutator APIs that work withVersionedcontainers- Specified by:
versionedin interfaceModeledFramework<T>- Returns:
- wrapped instance
-
modelSpec
public ModelSpec<T> modelSpec()
Description copied from interface:ModeledFrameworkReturn the model being used- Specified by:
modelSpecin interfaceModeledFramework<T>- Returns:
- model
-
unwrap
public AsyncCuratorFramework unwrap()
Description copied from interface:ModeledFrameworkReturns the client that was originally passed toModeledFramework.wrap(org.apache.curator.x.async.AsyncCuratorFramework, ModelSpec)or the builder.- Specified by:
unwrapin interfaceModeledFramework<T>- Returns:
- original client
-
set
public AsyncStage<java.lang.String> set(T item)
Description copied from interface:ModeledFrameworkCreate (or update depending on build options) a ZNode at this instance's path with a serialized version of the given model- Specified by:
setin interfaceModeledFramework<T>- Parameters:
item- model to write- Returns:
- AsyncStage
- See Also:
AsyncStage
-
set
public AsyncStage<java.lang.String> set(T item, org.apache.zookeeper.data.Stat storingStatIn)
Description copied from interface:ModeledFrameworkCreate (or update depending on build options) a ZNode at this instance's path with a serialized form of the given model- Specified by:
setin interfaceModeledFramework<T>- Parameters:
item- model to writestoringStatIn- the stat for the new ZNode is stored here- Returns:
- AsyncStage
- See Also:
AsyncStage
-
set
public AsyncStage<java.lang.String> set(T item, int version)
Description copied from interface:ModeledFrameworkCreate (or update depending on build options) a ZNode at this instance's path with a serialized version of the given model- Specified by:
setin interfaceModeledFramework<T>- Parameters:
item- model to writeversion- if data is being set instead of creating the node, the data version to use- Returns:
- AsyncStage
- See Also:
AsyncStage
-
set
public AsyncStage<java.lang.String> set(T item, org.apache.zookeeper.data.Stat storingStatIn, int version)
Description copied from interface:ModeledFrameworkCreate (or update depending on build options) a ZNode at this instance's path with a serialized form of the given model- Specified by:
setin interfaceModeledFramework<T>- Parameters:
item- model to writestoringStatIn- the stat for the new ZNode is stored hereversion- if data is being set instead of creating the node, the data version to use- Returns:
- AsyncStage
- See Also:
AsyncStage
-
read
public AsyncStage<T> read()
Description copied from interface:ModeledFrameworkRead the ZNode at this instance's path and deserialize into a model- Specified by:
readin interfaceModeledFramework<T>- Returns:
- AsyncStage
- See Also:
AsyncStage
-
read
public AsyncStage<T> read(org.apache.zookeeper.data.Stat storingStatIn)
Description copied from interface:ModeledFrameworkRead the ZNode at this instance's path and deserialize into a model- Specified by:
readin interfaceModeledFramework<T>- Parameters:
storingStatIn- the stat for the new ZNode is stored here- Returns:
- AsyncStage
- See Also:
AsyncStage
-
readAsZNode
public AsyncStage<ZNode<T>> readAsZNode()
Description copied from interface:ModeledFrameworkRead the ZNode at this instance's path and deserialize into a model- Specified by:
readAsZNodein interfaceModeledFramework<T>- Returns:
- AsyncStage
- See Also:
AsyncStage
-
update
public AsyncStage<org.apache.zookeeper.data.Stat> update(T item)
Description copied from interface:ModeledFrameworkUpdate the ZNode at this instance's path with a serialized form of the given model passing "-1" for the update version- Specified by:
updatein interfaceModeledFramework<T>- Parameters:
item- model to write- Returns:
- AsyncStage
- See Also:
AsyncStage
-
update
public AsyncStage<org.apache.zookeeper.data.Stat> update(T item, int version)
Description copied from interface:ModeledFrameworkUpdate the ZNode at this instance's path with a serialized form of the given model passing the given update version- Specified by:
updatein interfaceModeledFramework<T>- Parameters:
item- model to writeversion- update version to use- Returns:
- AsyncStage
- See Also:
AsyncStage
-
checkExists
public AsyncStage<org.apache.zookeeper.data.Stat> checkExists()
Description copied from interface:ModeledFrameworkCheck to see if the ZNode at this instance's path exists- Specified by:
checkExistsin interfaceModeledFramework<T>- Returns:
- AsyncStage
- See Also:
AsyncStage
-
delete
public AsyncStage<java.lang.Void> delete()
Description copied from interface:ModeledFrameworkDelete the ZNode at this instance's path passing -1 for the delete version- Specified by:
deletein interfaceModeledFramework<T>- Returns:
- AsyncStage
- See Also:
AsyncStage
-
delete
public AsyncStage<java.lang.Void> delete(int version)
Description copied from interface:ModeledFrameworkDelete the ZNode at this instance's path passing the given delete version- Specified by:
deletein interfaceModeledFramework<T>- Parameters:
version- update version to use- Returns:
- AsyncStage
- See Also:
AsyncStage
-
children
public AsyncStage<java.util.List<ZPath>> children()
Description copied from interface:ModeledFrameworkReturn the child paths of this instance's path (in no particular order)- Specified by:
childrenin interfaceModeledFramework<T>- Returns:
- AsyncStage
- See Also:
AsyncStage
-
childrenAsZNodes
public AsyncStage<java.util.List<ZNode<T>>> childrenAsZNodes()
Description copied from interface:ModeledFrameworkReturn the child paths of this instance's path (in no particular order) and deserialize into a models. IMPORTANT: this results in a ZooKeeper query for each child node returned. i.e. if the initial children() call returns 10 nodes an additional 10 ZooKeeper queries are made to get the data. Note: cannot be used if any of theModeledFrameworkBuilder.watched()modes are used.- Specified by:
childrenAsZNodesin interfaceModeledFramework<T>- Returns:
- AsyncStage
- See Also:
AsyncStage
-
parent
public ModeledFramework<T> parent()
Description copied from interface:ModeledFrameworkReturn a new Modeled Curator instance with all the same options but applying to the parent node of this Modeled Curator's path. E.g. if this Modeled Curator instance applies to "/a/b/c", calling
modeled.parent()returns an instance that applies to "/a/b".The replacement is the
toString()value of child or, if it implementsNodeName, the value ofnodeName().- Specified by:
parentin interfaceModeledFramework<T>- Returns:
- new Modeled Curator instance
-
child
public ModeledFramework<T> child(java.lang.Object child)
Description copied from interface:ModeledFrameworkReturn a new Modeled Curator instance with all the same options but applying to the given child node of this Modeled Curator's path. E.g. if this Modeled Curator instance applies to "/a/b", calling
modeled.at("c")returns an instance that applies to "/a/b/c".The replacement is the
toString()value of child or, if it implementsNodeName, the value ofnodeName().- Specified by:
childin interfaceModeledFramework<T>- Parameters:
child- child node.- Returns:
- new Modeled Curator instance
-
withPath
public ModeledFramework<T> withPath(ZPath path)
Description copied from interface:ModeledFrameworkReturn a Modeled Curator instance with all the same options but using the given path.- Specified by:
withPathin interfaceModeledFramework<T>- Parameters:
path- new path- Returns:
- new Modeled Curator instance
-
isCompressed
public static boolean isCompressed(java.util.Set<CreateOption> createOptions)
-
createOp
public org.apache.curator.framework.api.transaction.CuratorOp createOp(T model)
Description copied from interface:ModeledFrameworkCreate operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction. Note: due to ZooKeeper transaction limits, this is a _not_ a "set or update" operation but only a create operation and will generate an error if the node already exists.- Specified by:
createOpin interfaceModeledFramework<T>- Parameters:
model- the model- Returns:
- operation
-
updateOp
public org.apache.curator.framework.api.transaction.CuratorOp updateOp(T model)
Description copied from interface:ModeledFrameworkUpdate operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.- Specified by:
updateOpin interfaceModeledFramework<T>- Parameters:
model- the model- Returns:
- operation
-
updateOp
public org.apache.curator.framework.api.transaction.CuratorOp updateOp(T model, int version)
Description copied from interface:ModeledFrameworkCreate operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.- Specified by:
updateOpin interfaceModeledFramework<T>- Parameters:
model- the modelversion- update version to use- Returns:
- operation
-
deleteOp
public org.apache.curator.framework.api.transaction.CuratorOp deleteOp()
Description copied from interface:ModeledFrameworkDelete operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.- Specified by:
deleteOpin interfaceModeledFramework<T>- Returns:
- operation
-
deleteOp
public org.apache.curator.framework.api.transaction.CuratorOp deleteOp(int version)
Description copied from interface:ModeledFrameworkDelete operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.- Specified by:
deleteOpin interfaceModeledFramework<T>- Parameters:
version- delete version to use- Returns:
- operation
-
checkExistsOp
public org.apache.curator.framework.api.transaction.CuratorOp checkExistsOp()
Description copied from interface:ModeledFrameworkCheck exists operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.- Specified by:
checkExistsOpin interfaceModeledFramework<T>- Returns:
- operation
-
checkExistsOp
public org.apache.curator.framework.api.transaction.CuratorOp checkExistsOp(int version)
Description copied from interface:ModeledFrameworkCheck exists operation instance that can be passed among other operations toModeledFramework.inTransaction(java.util.List)to be executed as a single transaction.- Specified by:
checkExistsOpin interfaceModeledFramework<T>- Parameters:
version- version to use- Returns:
- operation
-
inTransaction
public AsyncStage<java.util.List<org.apache.curator.framework.api.transaction.CuratorTransactionResult>> inTransaction(java.util.List<org.apache.curator.framework.api.transaction.CuratorOp> operations)
Description copied from interface:ModeledFrameworkInvoke ZooKeeper to commit the given operations as a single transaction.- Specified by:
inTransactionin interfaceModeledFramework<T>- Parameters:
operations- operations that make up the transaction.- Returns:
- AsyncStage instance for managing the completion
-
-