You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2017/02/09 18:36:36 UTC
[37/47] curator git commit: added info to pom - doc fixes
added info to pom - doc fixes
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8f592095
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8f592095
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8f592095
Branch: refs/heads/CURATOR-3.0
Commit: 8f592095d295a7dffe44fb6b0432d703bd4cf5b4
Parents: 21f3ac2
Author: randgalt <ra...@apache.org>
Authored: Sun Jan 8 09:41:54 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jan 8 09:41:54 2017 -0500
----------------------------------------------------------------------
curator-x-async/pom.xml | 4 ++++
.../src/site/confluence/index.confluence | 18 ++++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/8f592095/curator-x-async/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-async/pom.xml b/curator-x-async/pom.xml
index e51e001..8821a47 100644
--- a/curator-x-async/pom.xml
+++ b/curator-x-async/pom.xml
@@ -9,6 +9,10 @@
<artifactId>curator-x-async</artifactId>
+ <name>Curator Async</name>
+ <description>Java 8 Async DSL</description>
+ <inceptionYear>2017</inceptionYear>
+
<dependencies>
<dependency>
<groupId>org.apache.curator</groupId>
http://git-wip-us.apache.org/repos/asf/curator/blob/8f592095/curator-x-async/src/site/confluence/index.confluence
----------------------------------------------------------------------
diff --git a/curator-x-async/src/site/confluence/index.confluence b/curator-x-async/src/site/confluence/index.confluence
index 757acc8..c896df7 100644
--- a/curator-x-async/src/site/confluence/index.confluence
+++ b/curator-x-async/src/site/confluence/index.confluence
@@ -6,13 +6,13 @@ Curator Async is in its own package in Maven Central: curator\-x\-async
h2. What Is a Curator Async?
-Curator Async is a brand new [DSL|https://en.wikipedia.org/wiki/Domain-specific_language] that wraps existing
-{{CuratorFramework}} instances. This new DSL is entirely asynchronous and uses
+Curator Async is a [DSL|https://en.wikipedia.org/wiki/Domain-specific_language] that wraps existing
+{{CuratorFramework}} instances. This DSL is entirely asynchronous and uses
[Java 8's CompletionStage|https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html]
mechanism for chaining, composing, etc. Additionally, Curator's original DSL has been cleaned up
and simplified, in particular for operations such as {{create()}}.
-With this new async DSL you can do asynchronous tasks in a more natural, functional way using
+With this DSL you can do asynchronous tasks in a more natural, functional way using
[Java 8 lambdas|https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html]. For example:
{code}
@@ -92,12 +92,14 @@ stage.event().exceptionally(e -> {
... note a connection problem ...
- asyncEx.reset().thenRun(() -> successMethod());
+ asyncEx.reset().thenAccept(watchedEvent -> watchWasTriggered(watchedEvent));
});
{code}
h2. Examples
+h4. Create a sequential ZNode
+
Create a sequential ZNode and, once successfully completed, set a watcher
on the ZNode. Note: this code does not deal with errors. Should a connection
problem occur or another exception occur, the completion lambda will never be called.
@@ -109,6 +111,8 @@ async.create().withMode(PERSISTENT_SEQUENTIAL).forPath(path).thenAccept(actualPa
----
+h4. AsyncStage canonical usage
+
This is the canonical way to deal with AsyncStage. Use the handle() method which provides
both the success value and the exception. The exception will be non\-null on error.
@@ -128,6 +132,8 @@ async.create().withOptions(EnumSet.of(doProtected)).forPath(path).handle((actual
----
+h4. Using executors
+
Your completion routines can operate in a separate thread if you provide an executor.
{code}
@@ -137,6 +143,8 @@ async.create().withOptions(EnumSet.of(createParentsIfNeeded)).forPath("/a/b/c")
----
+h4. Separate handlers
+
This example shows specifying separate completion handlers for success and exception.
{code}
@@ -157,6 +165,8 @@ stage.thenAccept(data -> processData(data));
----
+h4. Synchronous usage
+
CompletionStage provides a blocking method as well so that you can block to get the result
of an operation. i.e. this makes it possible to use the async APIs in a synchronous way.