public class ModeledFrameworkImpl<T> extends Object implements ModeledFramework<T>
Modifier and Type | Method and Description |
---|---|
static <T> ModeledFrameworkImpl<T> |
build(AsyncCuratorFramework client,
ModelSpec<T> model,
WatchMode watchMode,
UnaryOperator<org.apache.zookeeper.WatchedEvent> watcherFilter,
UnhandledErrorListener unhandledErrorListener,
UnaryOperator<CuratorEvent> resultFilter,
Set<ModeledOptions> modeledOptions) |
CachedModeledFramework<T> |
cached()
Use an internally created cache as a front for this modeled instance.
|
CachedModeledFramework<T> |
cached(ExecutorService executor)
Same as
ModeledFramework.cached() but allows for providing an executor service |
AsyncStage<org.apache.zookeeper.data.Stat> |
checkExists()
Check to see if the ZNode at this instance's path exists
|
CuratorOp |
checkExistsOp()
Check exists operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
CuratorOp |
checkExistsOp(int version)
Check exists operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
ModeledFramework<T> |
child(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<List<ZPath>> |
children()
Return the child paths of this instance's path (in no particular order)
|
AsyncStage<List<ZNode<T>>> |
childrenAsZNodes()
Return the child paths of this instance's path (in no particular order)
and deserialize into a models.
|
CuratorOp |
createOp(T model)
Create operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
AsyncStage<Void> |
delete()
Delete the ZNode at this instance's path passing -1 for the delete version
|
AsyncStage<Void> |
delete(int version)
Delete the ZNode at this instance's path passing the given delete version
|
CuratorOp |
deleteOp()
Delete operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
CuratorOp |
deleteOp(int version)
Delete operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
AsyncStage<List<CuratorTransactionResult>> |
inTransaction(List<CuratorOp> operations)
Invoke ZooKeeper to commit the given operations as a single transaction.
|
static boolean |
isCompressed(Set<CreateOption> createOptions) |
ModelSpec<T> |
modelSpec()
Return the model being used
|
ModeledFramework<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 model
|
AsyncStage<T> |
read(org.apache.zookeeper.data.Stat storingStatIn)
Read the ZNode at this instance's path and deserialize into a model
|
AsyncStage<ZNode<T>> |
readAsZNode()
Read the ZNode at this instance's path and deserialize into a model
|
AsyncStage<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 model
|
AsyncStage<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 model
|
AsyncStage<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 model
|
AsyncStage<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 model
|
AsyncCuratorFramework |
unwrap()
Returns the client that was originally passed to
ModeledFramework.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 version
|
AsyncStage<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 version
|
CuratorOp |
updateOp(T model)
Update operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
CuratorOp |
updateOp(T model,
int version)
Create operation instance that can be passed among other operations to
ModeledFramework.inTransaction(java.util.List) to be executed as a single transaction. |
VersionedModeledFramework<T> |
versioned()
Return mutator APIs that work with
Versioned containers |
ModeledFramework<T> |
withPath(ZPath path)
Return a Modeled Curator instance with all the same options but using the given path.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, builder, wrap
public static <T> ModeledFrameworkImpl<T> build(AsyncCuratorFramework client, ModelSpec<T> model, WatchMode watchMode, UnaryOperator<org.apache.zookeeper.WatchedEvent> watcherFilter, UnhandledErrorListener unhandledErrorListener, UnaryOperator<CuratorEvent> resultFilter, Set<ModeledOptions> modeledOptions)
public CachedModeledFramework<T> cached()
ModeledFramework
Use 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()
and
CachedModeledFramework.close()
to start/stop
Note: 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.
cached
in interface ModeledFramework<T>
public CachedModeledFramework<T> cached(ExecutorService executor)
ModeledFramework
ModeledFramework.cached()
but allows for providing an executor servicecached
in interface ModeledFramework<T>
executor
- thread pool to use for the cache and for read operationspublic VersionedModeledFramework<T> versioned()
ModeledFramework
Versioned
containersversioned
in interface ModeledFramework<T>
public ModelSpec<T> modelSpec()
ModeledFramework
modelSpec
in interface ModeledFramework<T>
public AsyncCuratorFramework unwrap()
ModeledFramework
ModeledFramework.wrap(org.apache.curator.x.async.AsyncCuratorFramework, ModelSpec)
or
the builder.unwrap
in interface ModeledFramework<T>
public AsyncStage<String> set(T item)
ModeledFramework
set
in interface ModeledFramework<T>
item
- model to writeAsyncStage
public AsyncStage<String> set(T item, org.apache.zookeeper.data.Stat storingStatIn)
ModeledFramework
set
in interface ModeledFramework<T>
item
- model to writestoringStatIn
- the stat for the new ZNode is stored hereAsyncStage
public AsyncStage<String> set(T item, int version)
ModeledFramework
set
in interface ModeledFramework<T>
item
- model to writeversion
- if data is being set instead of creating the node, the data version to useAsyncStage
public AsyncStage<String> set(T item, org.apache.zookeeper.data.Stat storingStatIn, int version)
ModeledFramework
set
in interface ModeledFramework<T>
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 useAsyncStage
public AsyncStage<T> read()
ModeledFramework
read
in interface ModeledFramework<T>
AsyncStage
public AsyncStage<T> read(org.apache.zookeeper.data.Stat storingStatIn)
ModeledFramework
read
in interface ModeledFramework<T>
storingStatIn
- the stat for the new ZNode is stored hereAsyncStage
public AsyncStage<ZNode<T>> readAsZNode()
ModeledFramework
readAsZNode
in interface ModeledFramework<T>
AsyncStage
public AsyncStage<org.apache.zookeeper.data.Stat> update(T item)
ModeledFramework
update
in interface ModeledFramework<T>
item
- model to writeAsyncStage
public AsyncStage<org.apache.zookeeper.data.Stat> update(T item, int version)
ModeledFramework
update
in interface ModeledFramework<T>
item
- model to writeversion
- update version to useAsyncStage
public AsyncStage<org.apache.zookeeper.data.Stat> checkExists()
ModeledFramework
checkExists
in interface ModeledFramework<T>
AsyncStage
public AsyncStage<Void> delete()
ModeledFramework
delete
in interface ModeledFramework<T>
AsyncStage
public AsyncStage<Void> delete(int version)
ModeledFramework
delete
in interface ModeledFramework<T>
version
- update version to useAsyncStage
public AsyncStage<List<ZPath>> children()
ModeledFramework
children
in interface ModeledFramework<T>
AsyncStage
public AsyncStage<List<ZNode<T>>> childrenAsZNodes()
ModeledFramework
ModeledFrameworkBuilder.watched()
modes
are used.childrenAsZNodes
in interface ModeledFramework<T>
AsyncStage
public ModeledFramework<T> parent()
ModeledFramework
Return 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 implements NodeName
,
the value of nodeName()
.
parent
in interface ModeledFramework<T>
public ModeledFramework<T> child(Object child)
ModeledFramework
Return 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 implements NodeName
,
the value of nodeName()
.
child
in interface ModeledFramework<T>
child
- child node.public ModeledFramework<T> withPath(ZPath path)
ModeledFramework
withPath
in interface ModeledFramework<T>
path
- new pathpublic static boolean isCompressed(Set<CreateOption> createOptions)
public CuratorOp createOp(T model)
ModeledFramework
ModeledFramework.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.createOp
in interface ModeledFramework<T>
model
- the modelpublic CuratorOp updateOp(T model)
ModeledFramework
ModeledFramework.inTransaction(java.util.List)
to be executed as a single transaction.updateOp
in interface ModeledFramework<T>
model
- the modelpublic CuratorOp updateOp(T model, int version)
ModeledFramework
ModeledFramework.inTransaction(java.util.List)
to be executed as a single transaction.updateOp
in interface ModeledFramework<T>
model
- the modelversion
- update version to usepublic CuratorOp deleteOp()
ModeledFramework
ModeledFramework.inTransaction(java.util.List)
to be executed as a single transaction.deleteOp
in interface ModeledFramework<T>
public CuratorOp deleteOp(int version)
ModeledFramework
ModeledFramework.inTransaction(java.util.List)
to be executed as a single transaction.deleteOp
in interface ModeledFramework<T>
version
- delete version to usepublic CuratorOp checkExistsOp()
ModeledFramework
ModeledFramework.inTransaction(java.util.List)
to be executed as a single transaction.checkExistsOp
in interface ModeledFramework<T>
public CuratorOp checkExistsOp(int version)
ModeledFramework
ModeledFramework.inTransaction(java.util.List)
to be executed as a single transaction.checkExistsOp
in interface ModeledFramework<T>
version
- version to usepublic AsyncStage<List<CuratorTransactionResult>> inTransaction(List<CuratorOp> operations)
ModeledFramework
inTransaction
in interface ModeledFramework<T>
operations
- operations that make up the transaction.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.