Repository: curator Updated Branches: refs/heads/CURATOR-397 1dab81b5a -> 0f0db1c38
more doc Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0f0db1c3 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0f0db1c3 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0f0db1c3 Branch: refs/heads/CURATOR-397 Commit: 0f0db1c386471dd4babdf3f26b37b1d9056b3f7d Parents: 1dab81b Author: randgalt <[email protected]> Authored: Sat Apr 8 15:15:12 2017 -0500 Committer: randgalt <[email protected]> Committed: Sat Apr 8 15:15:12 2017 -0500 ---------------------------------------------------------------------- .../modeled/ModeledAsyncCuratorFramework.java | 82 +++++++++++++++++++- .../ModeledAsyncCuratorFrameworkBuilder.java | 63 +++++++++++++++ 2 files changed, 144 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/0f0db1c3/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFramework.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFramework.java b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFramework.java index 6acc77c..17c6c8e 100644 --- a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFramework.java +++ b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFramework.java @@ -37,7 +37,7 @@ public interface ModeledAsyncCuratorFramework<T> * @param client Curator client * @param path path to model * @param serializer the model's serializer - * @return Modeled Curator instance + * @return new Modeled Curator instance */ static <T> ModeledAsyncCuratorFramework<T> wrap(CuratorFramework client, ZPath path, ModelSerializer<T> serializer) { @@ -61,25 +61,105 @@ public interface ModeledAsyncCuratorFramework<T> .withDeleteOptions(defaultDeleteOptions); } + /** + * Returns the client that was originally passed to {@link #wrap(org.apache.curator.framework.CuratorFramework, ZPath, ModelSerializer)} or + * the builder. + * + * @return original client + */ CuratorFramework unwrap(); + /** + * 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 <code>modeled.at("c")</code> returns an instance that applies to + * "/a/b/c". + * + * @param child child node. + * @return new Modeled Curator instance + */ ModeledAsyncCuratorFramework<T> at(String child); + /** + * Create (or update depending on build options) a ZNode at this instance's path with a serialized + * version of the given model + * + * @param model model to write + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<String> create(T model); + /** + * Create (or update depending on build options) a ZNode at this instance's path with a serialized + * form of the given model + * + * @param model model to write + * @param storingStatIn the stat for the new ZNode is stored here + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<String> create(T model, Stat storingStatIn); + /** + * Read the ZNode at this instance's path and deserialize into a model + * + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<T> read(); + /** + * Read the ZNode at this instance's path and deserialize into a model + * + * @param storingStatIn the stat for the new ZNode is stored here + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<T> read(Stat storingStatIn); + /** + * Update the ZNode at this instance's path with a serialized + * form of the given model passing "-1" for the update version + * + * @param model model to write + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<Stat> update(T model); + /** + * Update the ZNode at this instance's path with a serialized + * form of the given model passing the given update version + * + * @param model model to write + * @param version update version to use + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<Stat> update(T model, int version); + /** + * Check to see if the ZNode at this instance's path exists + * + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<Stat> checkExists(); + /** + * Delete the ZNode at this instance's path passing -1 for the delete version + * + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<Void> delete(); + /** + * Delete the ZNode at this instance's path passing the given delete version + * + * @param version update version to use + * @return AsyncStage + * @see org.apache.curator.x.async.AsyncStage + */ AsyncStage<Void> delete(int version); } http://git-wip-us.apache.org/repos/asf/curator/blob/0f0db1c3/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFrameworkBuilder.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFrameworkBuilder.java b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFrameworkBuilder.java index b328220..b7e83d3 100644 --- a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFrameworkBuilder.java +++ b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ModeledAsyncCuratorFrameworkBuilder.java @@ -48,6 +48,11 @@ public class ModeledAsyncCuratorFrameworkBuilder<T> private Set<CreateOption> createOptions; private Set<DeleteOption> deleteOptions; + /** + * Build a new ModeledAsyncCuratorFramework instance + * + * @return new ModeledAsyncCuratorFramework instance + */ public ModeledAsyncCuratorFramework<T> build() { return new ModeledAsyncCuratorFrameworkImpl<>( @@ -65,18 +70,40 @@ public class ModeledAsyncCuratorFrameworkBuilder<T> ); } + /** + * Add watchers as appropriate to the Modeled Curator's ZNode using + * {@link org.apache.curator.x.async.WatchMode#stateChangeAndSuccess} + * + * @return this for chaining + * @see org.apache.curator.x.async.AsyncStage#event() + */ public ModeledAsyncCuratorFrameworkBuilder<T> watched() { this.watchMode = WatchMode.stateChangeAndSuccess; return this; } + /** + * Add watchers as appropriate using the given watchMode to the Modeled Curator's ZNode + * + * @param watchMode watcher style + * @return this for chaining + * @see org.apache.curator.x.async.AsyncStage#event() + */ public ModeledAsyncCuratorFrameworkBuilder<T> watched(WatchMode watchMode) { this.watchMode = watchMode; return this; } + /** + * Add watchers as appropriate using the given watchMode and filter to the Modeled Curator's ZNode + * + * @param watchMode watcher style + * @param watcherFilter filter + * @return this for chaining + * @see org.apache.curator.x.async.AsyncStage#event() + */ public ModeledAsyncCuratorFrameworkBuilder<T> watched(WatchMode watchMode, UnaryOperator<WatchedEvent> watcherFilter) { this.watchMode = watchMode; @@ -84,36 +111,72 @@ public class ModeledAsyncCuratorFrameworkBuilder<T> return this; } + /** + * Use the given unhandledErrorListener for operations on the Modeled Curator's ZNode + * + * @param unhandledErrorListener listener + * @return this for chaining + */ public ModeledAsyncCuratorFrameworkBuilder<T> withUnhandledErrorListener(UnhandledErrorListener unhandledErrorListener) { this.unhandledErrorListener = unhandledErrorListener; return this; } + /** + * Use the given result filter for operations on the Modeled Curator's ZNode + * + * @param resultFilter filter + * @return this for chaining + */ public ModeledAsyncCuratorFrameworkBuilder<T> withResultFilter(UnaryOperator<CuratorEvent> resultFilter) { this.resultFilter = resultFilter; return this; } + /** + * Use the given createMode for create operations on the Modeled Curator's ZNode + * + * @param createMode create mode + * @return this for chaining + */ public ModeledAsyncCuratorFrameworkBuilder<T> withCreateMode(CreateMode createMode) { this.createMode = createMode; return this; } + /** + * Use the given aclList for create operations on the Modeled Curator's ZNode + * + * @param aclList ACLs + * @return this for chaining + */ public ModeledAsyncCuratorFrameworkBuilder<T> withAclList(List<ACL> aclList) { this.aclList = aclList; return this; } + /** + * Use the given create options on the Modeled Curator's ZNode + * + * @param createOptions options + * @return this for chaining + */ public ModeledAsyncCuratorFrameworkBuilder<T> withCreateOptions(Set<CreateOption> createOptions) { this.createOptions = (createOptions != null) ? ImmutableSet.copyOf(createOptions) : null; return this; } + /** + * Use the given delete options on the Modeled Curator's ZNode + * + * @param deleteOptions options + * @return this for chaining + */ public ModeledAsyncCuratorFrameworkBuilder<T> withDeleteOptions(Set<DeleteOption> deleteOptions) { this.deleteOptions = (deleteOptions != null) ? ImmutableSet.copyOf(deleteOptions) : null;
