You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by dr...@apache.org on 2017/05/02 20:06:47 UTC
[39/50] curator git commit: Merge branch 'CURATOR-3.0' into
CURATOR-351
Merge branch 'CURATOR-3.0' into CURATOR-351
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1826b66d
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1826b66d
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1826b66d
Branch: refs/heads/master
Commit: 1826b66d72f6e543a57aaf5f3acc3cd9ca6e965d
Parents: e7d57ec b3939ac
Author: randgalt <ra...@apache.org>
Authored: Mon Apr 3 10:54:50 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Apr 3 10:54:50 2017 -0500
----------------------------------------------------------------------
README | 7 -
README.md | 11 +
curator-client/pom.xml | 44 +-
.../org/apache/curator/ConnectionState.java | 18 +-
.../ensemble/fixed/FixedEnsembleProvider.java | 4 +-
.../org/apache/curator/utils/DebugUtils.java | 1 +
curator-examples/pom.xml | 2 +-
curator-framework/pom.xml | 4 +-
.../curator/framework/CuratorFramework.java | 1 +
.../curator/framework/api/CreateBuilder.java | 10 +
.../curator/framework/api/CreateBuilder2.java | 10 +
.../curator/framework/api/ExistsBuilder.java | 7 +
.../curator/framework/imps/Backgrounding.java | 10 +-
.../framework/imps/CreateBuilderImpl.java | 24 +-
.../imps/CuratorMultiTransactionImpl.java | 6 +
.../framework/imps/DeleteBuilderImpl.java | 12 +-
.../curator/framework/imps/EnsembleTracker.java | 4 +-
.../framework/imps/ExistsBuilderImpl.java | 29 +-
.../framework/imps/GetACLBuilderImpl.java | 9 +-
.../framework/imps/GetChildrenBuilderImpl.java | 10 +-
.../framework/imps/GetConfigBuilderImpl.java | 8 +
.../framework/imps/GetDataBuilderImpl.java | 11 +-
.../curator/framework/imps/NamespaceImpl.java | 2 +-
.../framework/imps/ReconfigBuilderImpl.java | 13 +-
.../imps/RemoveWatchesBuilderImpl.java | 12 +
.../framework/imps/SetACLBuilderImpl.java | 10 +-
.../framework/imps/SetDataBuilderImpl.java | 10 +-
.../curator/framework/imps/SyncBuilderImpl.java | 6 +
.../src/site/confluence/index.confluence | 2 +
.../framework/imps/TestNamespaceFacade.java | 10 +
curator-recipes/pom.xml | 10 +-
.../recipes/cache/PathChildrenCache.java | 2 +-
.../framework/recipes/cache/TreeCache.java | 67 +-
.../recipes/leader/LeaderSelector.java | 48 +-
.../recipes/locks/InterProcessSemaphore.java | 6 +
.../locks/InterProcessSemaphoreMutex.java | 13 +-
.../recipes/locks/InterProcessSemaphoreV2.java | 5 +
.../curator/framework/recipes/locks/Lease.java | 8 +
.../framework/recipes/nodes/PersistentNode.java | 28 +-
.../cache/TestPathChildrenCacheInCluster.java | 60 ++
.../recipes/leader/TestLeaderAcls.java | 133 ++++
.../recipes/leader/TestLeaderSelector.java | 2 +-
.../leader/TestLeaderSelectorParticipants.java | 2 +-
.../locks/TestInterProcessSemaphore.java | 11 +-
.../recipes/nodes/TestGroupMember.java | 28 +-
.../nodes/TestPersistentEphemeralNode.java | 52 +-
curator-test/pom.xml | 51 +-
.../apache/curator/test/BaseClassForTests.java | 148 ++++-
.../org/apache/curator/test/InstanceSpec.java | 58 +-
.../curator/test/QuorumConfigBuilder.java | 9 +-
.../curator/test/TestQuorumConfigBuilder.java | 49 ++
curator-x-async/pom.xml | 46 ++
.../curator/x/async/AsyncCuratorFramework.java | 110 ++++
.../curator/x/async/AsyncEventException.java | 46 ++
.../org/apache/curator/x/async/AsyncResult.java | 118 ++++
.../org/apache/curator/x/async/AsyncStage.java | 37 ++
.../org/apache/curator/x/async/WatchMode.java | 43 ++
.../curator/x/async/api/AsyncCreateBuilder.java | 144 +++++
.../x/async/api/AsyncCuratorFrameworkDsl.java | 116 ++++
.../curator/x/async/api/AsyncDeleteBuilder.java | 55 ++
.../curator/x/async/api/AsyncEnsemblable.java | 32 +
.../curator/x/async/api/AsyncExistsBuilder.java | 37 ++
.../curator/x/async/api/AsyncGetACLBuilder.java | 38 ++
.../x/async/api/AsyncGetChildrenBuilder.java | 37 ++
.../x/async/api/AsyncGetConfigBuilder.java | 36 ++
.../x/async/api/AsyncGetDataBuilder.java | 53 ++
.../x/async/api/AsyncMultiTransaction.java | 39 ++
.../x/async/api/AsyncPathAndBytesable.java | 36 ++
.../curator/x/async/api/AsyncPathable.java | 34 +
.../x/async/api/AsyncReconfigBuilder.java | 118 ++++
.../x/async/api/AsyncRemoveWatchesBuilder.java | 126 ++++
.../curator/x/async/api/AsyncSetACLBuilder.java | 49 ++
.../x/async/api/AsyncSetDataBuilder.java | 54 ++
.../curator/x/async/api/AsyncSyncBuilder.java | 29 +
.../async/api/AsyncTransactionCheckBuilder.java | 35 +
.../api/AsyncTransactionCreateBuilder.java | 66 ++
.../api/AsyncTransactionDeleteBuilder.java | 35 +
.../curator/x/async/api/AsyncTransactionOp.java | 54 ++
.../api/AsyncTransactionSetDataBuilder.java | 51 ++
.../curator/x/async/api/CreateOption.java | 76 +++
.../curator/x/async/api/DeleteOption.java | 44 ++
.../curator/x/async/api/ExistsOption.java | 35 +
.../x/async/api/RemoveWatcherOption.java | 45 ++
.../api/WatchableAsyncCuratorFramework.java | 54 ++
.../x/async/details/AsyncCreateBuilderImpl.java | 164 +++++
.../details/AsyncCuratorFrameworkImpl.java | 228 +++++++
.../x/async/details/AsyncDeleteBuilderImpl.java | 75 +++
.../x/async/details/AsyncExistsBuilderImpl.java | 69 ++
.../details/AsyncGetChildrenBuilderImpl.java | 61 ++
.../details/AsyncGetConfigBuilderImpl.java | 60 ++
.../async/details/AsyncGetDataBuilderImpl.java | 76 +++
.../async/details/AsyncReconfigBuilderImpl.java | 125 ++++
.../details/AsyncRemoveWatchesBuilderImpl.java | 174 +++++
.../x/async/details/AsyncResultImpl.java | 142 +++++
.../x/async/details/AsyncSetACLBuilderImpl.java | 68 ++
.../async/details/AsyncSetDataBuilderImpl.java | 84 +++
.../x/async/details/AsyncTransactionOpImpl.java | 233 +++++++
.../curator/x/async/details/BackgroundProc.java | 27 +
.../x/async/details/BackgroundProcs.java | 83 +++
.../curator/x/async/details/BuilderCommon.java | 41 ++
.../apache/curator/x/async/details/Filters.java | 53 ++
.../x/async/details/InternalCallback.java | 55 ++
.../x/async/details/InternalWatcher.java | 96 +++
.../src/site/confluence/index.confluence | 224 +++++++
curator-x-async/src/site/site.xml | 33 +
.../curator/framework/imps/TestFramework.java | 631 +++++++++++++++++++
.../framework/imps/TestFrameworkBackground.java | 290 +++++++++
.../curator/x/async/TestBasicOperations.java | 216 +++++++
curator-x-discovery-server/pom.xml | 4 +-
curator-x-discovery/pom.xml | 10 +-
.../curator/x/discovery/ServiceInstance.java | 32 +-
.../x/discovery/ServiceInstanceBuilder.java | 9 +-
.../discovery/details/ServiceProviderImpl.java | 8 +
.../x/discovery/TestJsonInstanceSerializer.java | 35 +-
.../discovery/details/TestServiceProvider.java | 109 ++++
curator-x-rpc/pom.xml | 4 +-
curator-x-rpc/src/site/site.xml | 2 +-
pom.xml | 63 +-
src/site/confluence/index.confluence | 2 +
src/site/site.xml | 1 +
120 files changed, 6435 insertions(+), 177 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder.java
----------------------------------------------------------------------
diff --cc curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder.java
index 431a945,564d11b..59b3510
--- a/curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder.java
@@@ -18,9 -18,8 +18,19 @@@
*/
package org.apache.curator.framework.api;
-public interface CreateBuilder extends
- CreateBuilderMain
+public interface CreateBuilder extends CreateBuilderMain
{
- CreateBuilderMain orSetData();
++ /**
++ * Specify a TTL when mode is {@link org.apache.zookeeper.CreateMode#PERSISTENT_WITH_TTL} or
++ * {@link org.apache.zookeeper.CreateMode#PERSISTENT_SEQUENTIAL_WITH_TTL}. If
++ * the znode has not been modified within the given TTL, it will be deleted once it has no
++ * children. The TTL unit is milliseconds and must be greater than 0 and less than or equal to
++ * EphemeralType.MAX_TTL.
++ *
++ * @param ttl the ttl
++ * @return this for chaining
++ */
+ CreateBuilderMain withTtl(long ttl);
+
+ CreateBuilder2 orSetData();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder2.java
----------------------------------------------------------------------
diff --cc curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder2.java
index 7e5c89a,0000000..ddc27c3
mode 100644,000000..100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder2.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/api/CreateBuilder2.java
@@@ -1,24 -1,0 +1,34 @@@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.curator.framework.api;
+
+public interface CreateBuilder2 extends CreateBuilderMain
+{
++ /**
++ * Specify a TTL when mode is {@link org.apache.zookeeper.CreateMode#PERSISTENT_WITH_TTL} or
++ * {@link org.apache.zookeeper.CreateMode#PERSISTENT_SEQUENTIAL_WITH_TTL}. If
++ * the znode has not been modified within the given TTL, it will be deleted once it has no
++ * children. The TTL unit is milliseconds and must be greater than 0 and less than or equal to
++ * EphemeralType.MAX_TTL.
++ *
++ * @param ttl the ttl
++ * @return this for chaining
++ */
+ CreateBuilderMain withTtl(long ttl);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
----------------------------------------------------------------------
diff --cc curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
index b3817bd,bbb98ea..b7d68e8
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
@@@ -41,7 -41,7 +41,7 @@@ import java.util.concurrent.Callable
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
- class CreateBuilderImpl implements CreateBuilder, CreateBuilder2, BackgroundOperation<PathAndBytes>, ErrorListenerPathAndBytesable<String>
-public class CreateBuilderImpl implements CreateBuilder, BackgroundOperation<PathAndBytes>, ErrorListenerPathAndBytesable<String>
++public class CreateBuilderImpl implements CreateBuilder, CreateBuilder2, BackgroundOperation<PathAndBytes>, ErrorListenerPathAndBytesable<String>
{
private final CuratorFrameworkImpl client;
private CreateMode createMode;
@@@ -75,11 -74,25 +75,27 @@@
setDataIfExists = false;
protectedId = null;
storingStat = null;
+ ttl = -1;
}
- public CreateBuilderImpl(CuratorFrameworkImpl client, CreateMode createMode, Backgrounding backgrounding, boolean createParentsIfNeeded, boolean createParentsAsContainers, boolean doProtected, boolean compress, boolean setDataIfExists, List<ACL> aclList, Stat storingStat)
++ public CreateBuilderImpl(CuratorFrameworkImpl client, CreateMode createMode, Backgrounding backgrounding, boolean createParentsIfNeeded, boolean createParentsAsContainers, boolean doProtected, boolean compress, boolean setDataIfExists, List<ACL> aclList, Stat storingStat, long ttl)
+ {
+ this.client = client;
+ this.createMode = createMode;
+ this.backgrounding = backgrounding;
+ this.createParentsIfNeeded = createParentsIfNeeded;
+ this.createParentsAsContainers = createParentsAsContainers;
+ this.doProtected = doProtected;
+ this.compress = compress;
+ this.setDataIfExists = setDataIfExists;
+ protectedId = null;
+ this.acling = new ACLing(client.getAclProvider(), aclList);
+ this.storingStat = storingStat;
++ this.ttl = ttl;
+ }
+
@Override
- public CreateBuilderMain orSetData()
+ public CreateBuilder2 orSetData()
{
setDataIfExists = true;
return this;
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
index e956266,b88a548..a45d0a8
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
@@@ -66,7 -65,6 +66,7 @@@ public class PersistentNode implements
private final AtomicReference<String> nodePath = new AtomicReference<String>(null);
private final String basePath;
private final CreateMode mode;
++ private final long ttl;
private final AtomicReference<byte[]> data = new AtomicReference<byte[]>();
private final AtomicReference<State> state = new AtomicReference<State>(State.LATENT);
private final AtomicBoolean authFailure = new AtomicBoolean(false);
@@@ -182,6 -173,6 +188,7 @@@
this.client = Preconditions.checkNotNull(givenClient, "client cannot be null").newWatcherRemoveCuratorFramework();
this.basePath = PathUtils.validatePath(basePath);
this.mode = Preconditions.checkNotNull(mode, "mode cannot be null");
++ this.ttl = ttl;
final byte[] data = Preconditions.checkNotNull(initData, "data cannot be null");
backgroundCallback = new BackgroundCallback()
@@@ -426,7 -415,17 +431,18 @@@
{
String existingPath = nodePath.get();
String createPath = (existingPath != null && !useProtection) ? existingPath : basePath;
- createMethod.withMode(getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data.get());
+
+ CreateModable<ACLBackgroundPathAndBytesable<String>> localCreateMethod = createMethod.get();
+ if ( localCreateMethod == null )
+ {
- CreateModable<ACLBackgroundPathAndBytesable<String>> tempCreateMethod = useProtection ? client.create().creatingParentContainersIfNeeded().withProtection() : client.create().creatingParentContainersIfNeeded();
++ CreateBuilderMain createBuilder = mode.isTTL() ? client.create().withTtl(ttl) : client.create();
++ CreateModable<ACLBackgroundPathAndBytesable<String>> tempCreateMethod = useProtection ? createBuilder.creatingParentContainersIfNeeded().withProtection() : createBuilder.creatingParentContainersIfNeeded();
+ if ( createMethod.compareAndSet(null, tempCreateMethod) )
+ {
+ localCreateMethod = tempCreateMethod;
+ }
+ }
+ localCreateMethod.withMode(getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data.get());
}
catch ( Exception e )
{
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/curator-x-async/src/main/java/org/apache/curator/x/async/api/AsyncCreateBuilder.java
----------------------------------------------------------------------
diff --cc curator-x-async/src/main/java/org/apache/curator/x/async/api/AsyncCreateBuilder.java
index 0000000,6f077bb..e5f2d8c
mode 000000,100644..100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/api/AsyncCreateBuilder.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/api/AsyncCreateBuilder.java
@@@ -1,0 -1,115 +1,144 @@@
+ /**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.curator.x.async.api;
+
+ import org.apache.curator.x.async.AsyncStage;
+ import org.apache.zookeeper.CreateMode;
+ import org.apache.zookeeper.data.ACL;
+ import org.apache.zookeeper.data.Stat;
+ import java.util.List;
+ import java.util.Set;
+
+ /**
+ * Builder for ZNode creates
+ */
+ public interface AsyncCreateBuilder extends AsyncPathAndBytesable<AsyncStage<String>>
+ {
+ /**
+ * Have the operation fill the provided stat object
+ *
+ * @param stat the stat to have filled in
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> storingStatIn(Stat stat);
+
+ /**
+ * Use the given create mode. The default is {@link org.apache.zookeeper.CreateMode#PERSISTENT}
+ *
+ * @param createMode mode to use
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withMode(CreateMode createMode);
+
+ /**
+ * Set an ACL list (default is {@link org.apache.zookeeper.ZooDefs.Ids#OPEN_ACL_UNSAFE})
+ *
+ * @param aclList the ACL list to use
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withACL(List<ACL> aclList);
+
+ /**
++ * Specify a TTL when mode is {@link org.apache.zookeeper.CreateMode#PERSISTENT_WITH_TTL} or
++ * {@link org.apache.zookeeper.CreateMode#PERSISTENT_SEQUENTIAL_WITH_TTL}. If
++ * the znode has not been modified within the given TTL, it will be deleted once it has no
++ * children. The TTL unit is milliseconds and must be greater than 0 and less than or equal to
++ * EphemeralType.MAX_TTL.
++ *
++ * @param ttl the ttl
++ * @return this for chaining
++ */
++ AsyncPathAndBytesable<AsyncStage<String>> withTtl(long ttl);
++
++ /**
+ * Options to change how the ZNode is created
+ *
+ * @param options options
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options);
+
+ /**
+ * set options and ACLs
+ *
+ * @param options options
+ * @param aclList the ACL list to use
+ * @see #withOptions(java.util.Set)
+ * @see #withACL(java.util.List)
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, List<ACL> aclList);
+
+ /**
+ * set options, mode and ACLs
+ *
+ * @param options options
+ * @param createMode mode to use
+ * @param aclList the ACL list to use
+ * @see #withACL(java.util.List)
+ * @see #withOptions(java.util.Set)
+ * @see #withMode(org.apache.zookeeper.CreateMode)
+ * @see #withACL(java.util.List)
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList);
+
+ /**
+ * set options and mode
+ *
+ * @param options options
+ * @param createMode mode to use
+ * @see #withOptions(java.util.Set)
+ * @see #withMode(org.apache.zookeeper.CreateMode)
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode);
+
+ /**
+ * set options, mode, ACLs, and stat
+ *
+ * @param options options
+ * @param createMode mode to use
+ * @param aclList the ACL list to use
+ * @param stat the stat to have filled in
+ * @see #withOptions(java.util.Set)
+ * @see #withMode(org.apache.zookeeper.CreateMode)
+ * @see #withACL(java.util.List)
+ * @see #storingStatIn(org.apache.zookeeper.data.Stat)
+ * @return this
+ */
+ AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList, Stat stat);
++
++ /**
++ * set options, mode, ACLs, and stat
++ *
++ * @param options options
++ * @param createMode mode to use
++ * @param aclList the ACL list to use
++ * @param stat the stat to have filled in
++ * @param ttl the ttl or 0
++ * @see #withOptions(java.util.Set)
++ * @see #withMode(org.apache.zookeeper.CreateMode)
++ * @see #withACL(java.util.List)
++ * @see #storingStatIn(org.apache.zookeeper.data.Stat)
++ * @see #withTtl(long)
++ * @return this
++ */
++ AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList, Stat stat, long ttl);
+ }
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
----------------------------------------------------------------------
diff --cc curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
index 0000000,b2b9000..e8b1d30
mode 000000,100644..100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
@@@ -1,0 -1,144 +1,164 @@@
+ /**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.curator.x.async.details;
+
+ import org.apache.curator.framework.imps.CreateBuilderImpl;
+ import org.apache.curator.framework.imps.CuratorFrameworkImpl;
+ import org.apache.curator.x.async.AsyncStage;
+ import org.apache.curator.x.async.api.AsyncCreateBuilder;
+ import org.apache.curator.x.async.api.AsyncPathAndBytesable;
+ import org.apache.curator.x.async.api.CreateOption;
+ import org.apache.zookeeper.CreateMode;
+ import org.apache.zookeeper.data.ACL;
+ import org.apache.zookeeper.data.Stat;
+ import java.util.Collections;
+ import java.util.List;
+ import java.util.Objects;
+ import java.util.Set;
+
+ import static org.apache.curator.x.async.details.BackgroundProcs.nameProc;
+ import static org.apache.curator.x.async.details.BackgroundProcs.safeCall;
+
+ class AsyncCreateBuilderImpl implements AsyncCreateBuilder
+ {
+ private final CuratorFrameworkImpl client;
+ private final Filters filters;
+ private CreateMode createMode = CreateMode.PERSISTENT;
+ private List<ACL> aclList = null;
+ private Set<CreateOption> options = Collections.emptySet();
+ private Stat stat = null;
++ private long ttl = -1;
+
+ AsyncCreateBuilderImpl(CuratorFrameworkImpl client, Filters filters)
+ {
+ this.client = client;
+ this.filters = filters;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> storingStatIn(Stat stat)
+ {
+ this.stat = stat;
+ return this;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withMode(CreateMode createMode)
+ {
+ this.createMode = Objects.requireNonNull(createMode, "createMode cannot be null");
+ return this;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withACL(List<ACL> aclList)
+ {
+ this.aclList = aclList;
+ return this;
+ }
+
+ @Override
++ public AsyncPathAndBytesable<AsyncStage<String>> withTtl(long ttl)
++ {
++ this.ttl = ttl;
++ return this;
++ }
++
++ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options)
+ {
+ this.options = Objects.requireNonNull(options, "options cannot be null");
+ return this;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, List<ACL> aclList)
+ {
+ this.options = Objects.requireNonNull(options, "options cannot be null");
+ this.aclList = aclList;
+ return this;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList)
+ {
+ this.options = Objects.requireNonNull(options, "options cannot be null");
+ this.aclList = aclList;
+ this.createMode = Objects.requireNonNull(createMode, "createMode cannot be null");
+ return this;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode)
+ {
+ this.options = Objects.requireNonNull(options, "options cannot be null");
+ this.createMode = Objects.requireNonNull(createMode, "createMode cannot be null");
+ return this;
+ }
+
+ @Override
+ public AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList, Stat stat)
+ {
+ this.options = Objects.requireNonNull(options, "options cannot be null");
+ this.aclList = aclList;
+ this.createMode = Objects.requireNonNull(createMode, "createMode cannot be null");
+ this.stat = stat;
+ return this;
+ }
+
+ @Override
++ public AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList, Stat stat, long ttl)
++ {
++ this.options = Objects.requireNonNull(options, "options cannot be null");
++ this.aclList = aclList;
++ this.createMode = Objects.requireNonNull(createMode, "createMode cannot be null");
++ this.stat = stat;
++ this.ttl = ttl;
++ return this;
++ }
++
++ @Override
+ public AsyncStage<String> forPath(String path)
+ {
+ return internalForPath(path, null, false);
+ }
+
+ @Override
+ public AsyncStage<String> forPath(String path, byte[] data)
+ {
+ return internalForPath(path, data, true);
+ }
+
+ private AsyncStage<String> internalForPath(String path, byte[] data, boolean useData)
+ {
+ BuilderCommon<String> common = new BuilderCommon<>(filters, nameProc);
+ CreateBuilderImpl builder = new CreateBuilderImpl(client,
+ createMode,
+ common.backgrounding,
+ options.contains(CreateOption.createParentsIfNeeded) || options.contains(CreateOption.createParentsAsContainers),
+ options.contains(CreateOption.createParentsAsContainers),
+ options.contains(CreateOption.doProtected),
+ options.contains(CreateOption.compress),
+ options.contains(CreateOption.setDataIfExists),
+ aclList,
- stat
++ stat,
++ ttl
+ );
+ return safeCall(common.internalCallback, () -> useData ? builder.forPath(path, data) : builder.forPath(path));
+ }
+ }
http://git-wip-us.apache.org/repos/asf/curator/blob/1826b66d/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index 4027ae7,34e724c..764ef2c
--- a/pom.xml
+++ b/pom.xml
@@@ -59,9 -59,9 +59,9 @@@
<jdk-version>1.7</jdk-version>
<!-- versions -->
- <zookeeper-version>3.5.1-alpha</zookeeper-version>
+ <zookeeper-version>3.5.3-beta</zookeeper-version>
<maven-project-info-reports-plugin-version>2.7</maven-project-info-reports-plugin-version>
- <maven-bundle-plugin-version>2.3.7</maven-bundle-plugin-version>
+ <maven-bundle-plugin-version>3.2.0</maven-bundle-plugin-version>
<maven-javadoc-plugin-version>2.10.3</maven-javadoc-plugin-version>
<doxia-module-confluence-version>1.6</doxia-module-confluence-version>
<maven-license-plugin-version>1.9.0</maven-license-plugin-version>