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:14 UTC
[15/47] curator git commit: wip - rewriting everything
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCuratorFrameworkDsl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCuratorFrameworkDsl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCuratorFrameworkDsl.java
new file mode 100644
index 0000000..a848b90
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCuratorFrameworkDsl.java
@@ -0,0 +1,124 @@
+/**
+ * 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.crimps.async;
+
+import org.apache.curator.framework.api.*;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+
+/**
+ * Zookeeper framework-style client
+ */
+public interface AsyncCuratorFrameworkDsl
+{
+ /**
+ * Start a create builder
+ *
+ * @return builder object
+ */
+ CreateBuilder create();
+
+ /**
+ * Start a delete builder
+ *
+ * @return builder object
+ */
+ AsyncDeleteBuilder delete();
+
+ /**
+ * Start an exists builder
+ * <p>
+ * The builder will return a Stat object as if org.apache.zookeeper.ZooKeeper.exists() were called. Thus, a null
+ * means that it does not exist and an actual Stat object means it does exist.
+ *
+ * @return builder object
+ */
+ ExistsBuilder checkExists();
+
+ /**
+ * Start a get data builder
+ *
+ * @return builder object
+ */
+ GetDataBuilder getData();
+
+ /**
+ * Start a set data builder
+ *
+ * @return builder object
+ */
+ AsyncSetDataBuilder setData();
+
+ /**
+ * Start a get children builder
+ *
+ * @return builder object
+ */
+ AsyncGetChildrenBuilder<CompletionStage<List<String>>> getChildren();
+
+ /**
+ * Start a get ACL builder
+ *
+ * @return builder object
+ */
+ GetACLBuilder getACL();
+
+ /**
+ * Start a set ACL builder
+ *
+ * @return builder object
+ */
+ SetACLBuilder setACL();
+
+ /**
+ * Start a reconfig builder
+ *
+ * @return builder object
+ */
+ ReconfigBuilder reconfig();
+
+ /**
+ * Start a getConfig builder
+ *
+ * @return builder object
+ */
+ GetConfigBuilder getConfig();
+
+ /**
+ * Start a transaction builder
+ *
+ * @return builder object
+ */
+ AsyncMultiTransaction transaction();
+
+ /**
+ * Start a sync builder. Note: sync is ALWAYS in the background even
+ * if you don't use one of the background() methods
+ *
+ * @return builder object
+ */
+ SyncBuilder sync();
+
+ /**
+ * Start a remove watches builder.
+ * @return builder object
+ */
+ RemoveWatchesBuilder watches();
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncDeleteBuilder.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncDeleteBuilder.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncDeleteBuilder.java
new file mode 100644
index 0000000..0fb728c
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncDeleteBuilder.java
@@ -0,0 +1,31 @@
+/**
+ * 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.crimps.async;
+
+import java.util.Set;
+import java.util.concurrent.CompletionStage;
+
+public interface AsyncDeleteBuilder extends AsyncPathable<CompletionStage<Void>>
+{
+ AsyncPathable<CompletionStage<Void>> withOptions(Set<DeleteOption> options);
+
+ AsyncPathable<CompletionStage<Void>> withOptionsAndVersion(Set<DeleteOption> options, int version);
+
+ AsyncPathable<CompletionStage<Void>> withVersion(int version);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncGetChildrenBuilder.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncGetChildrenBuilder.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncGetChildrenBuilder.java
new file mode 100644
index 0000000..90e0f4d
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncGetChildrenBuilder.java
@@ -0,0 +1,29 @@
+/**
+ * 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.crimps.async;
+
+import org.apache.curator.framework.api.Statable;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+
+public interface AsyncGetChildrenBuilder<T> extends
+ AsyncPathable<T>,
+ Statable<AsyncPathable<T>>
+{
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncMultiTransaction.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncMultiTransaction.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncMultiTransaction.java
new file mode 100644
index 0000000..1a7652c
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncMultiTransaction.java
@@ -0,0 +1,37 @@
+/**
+ * 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.crimps.async;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.transaction.CuratorOp;
+import org.apache.curator.framework.api.transaction.CuratorTransactionResult;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+
+public interface AsyncMultiTransaction
+{
+ /**
+ * Commit the given operations as a single transaction. Create the
+ * operation instances via {@link CuratorFramework#transactionOp()}
+ *
+ * @param operations operations that make up the transaction.
+ * @return result details for foreground operations or <code>null</code> for background operations
+ */
+ CompletionStage<List<CuratorTransactionResult>> forOperations(List<CuratorOp> operations);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathAndBytesable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathAndBytesable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathAndBytesable.java
new file mode 100644
index 0000000..f90722b
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathAndBytesable.java
@@ -0,0 +1,32 @@
+/**
+ * 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.crimps.async;
+
+public interface AsyncPathAndBytesable<T> extends AsyncPathable<T>
+{
+ /**
+ * Commit the currently building operation using the given path and data
+ *
+ * @param path the path
+ * @param data the data
+ * @return operation result if any
+ */
+ T forPath(String path, byte[] data);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathable.java
new file mode 100644
index 0000000..a8f4e8f
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncPathable.java
@@ -0,0 +1,31 @@
+/**
+ * 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.crimps.async;
+
+public interface AsyncPathable<T>
+{
+ /**
+ * Commit the currently building operation using the given path
+ *
+ * @param path the path
+ * @return operation result if any
+ */
+ T forPath(String path);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncSetDataBuilder.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncSetDataBuilder.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncSetDataBuilder.java
new file mode 100644
index 0000000..5fd74bd
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncSetDataBuilder.java
@@ -0,0 +1,36 @@
+/**
+ * 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.crimps.async;
+
+import org.apache.zookeeper.data.Stat;
+import java.util.concurrent.CompletionStage;
+
+public interface AsyncSetDataBuilder extends AsyncPathAndBytesable<CompletionStage<Stat>>
+{
+ /**
+ * Cause the data to be compressed using the configured compression provider
+ *
+ * @return this
+ */
+ AsyncPathAndBytesable<CompletionStage<Stat>> compressed();
+
+ AsyncPathAndBytesable<CompletionStage<Stat>> compressedWithVersion(int version);
+
+ AsyncPathAndBytesable<CompletionStage<Stat>> withVersion(int version);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncWatchedGetChildrenBuilder.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncWatchedGetChildrenBuilder.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncWatchedGetChildrenBuilder.java
new file mode 100644
index 0000000..27b2dbd
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncWatchedGetChildrenBuilder.java
@@ -0,0 +1,29 @@
+/**
+ * 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.crimps.async;
+
+import org.apache.curator.framework.api.Statable;
+import org.apache.curator.x.crimps.async.details.Crimped;
+import java.util.List;
+
+public interface AsyncWatchedGetChildrenBuilder extends
+ AsyncPathable<Crimped<List<String>>>,
+ Statable<AsyncPathable<Crimped<List<String>>>>
+{
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
deleted file mode 100644
index bad0fbe..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.api.CuratorEvent;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.BiFunction;
-
-interface BackgroundProc<T> extends BiFunction<CuratorEvent, CompletableFuture<T>, Void>
-{
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimped.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimped.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimped.java
deleted file mode 100644
index dc69019..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimped.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.zookeeper.WatchedEvent;
-import java.util.concurrent.CompletionStage;
-
-public interface Crimped<T> extends CompletionStage<T>
-{
- CompletionStage<WatchedEvent> event();
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
deleted file mode 100644
index 9d9a6fe..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.BackgroundCallback;
-import org.apache.curator.framework.api.CuratorEvent;
-import org.apache.zookeeper.WatchedEvent;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-
-class CrimpedBackgroundCallback<T> extends CompletableFuture<T> implements BackgroundCallback, Crimped<T>
-{
- private final BackgroundProc<T> resultFunction;
- private final CrimpedWatcher watcher;
-
- CrimpedBackgroundCallback(BackgroundProc<T> resultFunction, CrimpedWatcher watcher)
- {
- this.resultFunction = resultFunction;
- this.watcher = watcher;
- }
-
- @Override
- public CompletionStage<WatchedEvent> event()
- {
- return watcher;
- }
-
- @Override
- public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
- {
- resultFunction.apply(event, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigEnsembleable.java
deleted file mode 100644
index 6d8811f..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigEnsembleable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.crimps.async;
-
-public interface CrimpedConfigEnsembleable<T> extends
- CrimpledEnsembleable<T>
-{
- /**
- * Sets the configuration version to use.
- * @param config The version of the configuration.
- * @return this
- */
- CrimpledEnsembleable<T> fromConfig(long config);
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleable.java
deleted file mode 100644
index 7824fb6..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleable.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.api.Statable;
-import java.util.concurrent.CompletionStage;
-
-public interface CrimpedEnsembleable extends
- CrimpedConfigEnsembleable<CompletionStage<byte[]>>,
- Statable<CrimpedConfigEnsembleable<CompletionStage<byte[]>>>,
- CrimpledEnsembleable<CompletionStage<byte[]>>
-{
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleableImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleableImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleableImpl.java
deleted file mode 100644
index b5b7a43..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedEnsembleableImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.api.ConfigureEnsembleable;
-import org.apache.curator.framework.api.Ensembleable;
-import org.apache.curator.framework.api.Statable;
-import org.apache.zookeeper.data.Stat;
-import java.util.concurrent.CompletionStage;
-
-class CrimpedEnsembleableImpl implements CrimpedEnsembleable
-{
- private final CrimpedBackgroundCallback<byte[]> callback;
- private final Statable<ConfigureEnsembleable> configBuilder;
- private Ensembleable<byte[]> ensembleable;
- private ConfigureEnsembleable configureEnsembleable;
-
- CrimpedEnsembleableImpl(Statable<ConfigureEnsembleable> configBuilder, CrimpedBackgroundCallback<byte[]> callback)
- {
- this.configBuilder = configBuilder;
- this.callback = callback;
- configureEnsembleable = configBuilder.storingStatIn(new Stat());
- ensembleable = configureEnsembleable;
- }
-
- CrimpedEnsembleableImpl(Ensembleable<byte[]> ensembleable, CrimpedBackgroundCallback<byte[]> callback)
- {
- this.ensembleable = ensembleable;
- this.configBuilder = null;
- this.callback = callback;
- configureEnsembleable = null;
- }
-
- @Override
- public CompletionStage<byte[]> forEnsemble()
- {
- try
- {
- ensembleable.forEnsemble();
- }
- catch ( Exception e )
- {
- callback.completeExceptionally(e);
- }
- return callback;
- }
-
- @Override
- public CrimpedConfigEnsembleable<CompletionStage<byte[]>> storingStatIn(Stat stat)
- {
- ensembleable = configureEnsembleable = configBuilder.storingStatIn(stat);
- return this;
- }
-
- @Override
- public CrimpledEnsembleable<CompletionStage<byte[]>> fromConfig(long config)
- {
- try
- {
- ensembleable = configureEnsembleable.fromConfig(config);
- }
- catch ( Exception e )
- {
- callback.completeExceptionally(e);
- }
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedMultiTransaction.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedMultiTransaction.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedMultiTransaction.java
deleted file mode 100644
index fdba7b8..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedMultiTransaction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.transaction.CuratorOp;
-import org.apache.curator.framework.api.transaction.CuratorTransactionResult;
-import java.util.List;
-import java.util.concurrent.CompletionStage;
-
-public interface CrimpedMultiTransaction
-{
- /**
- * Commit the given operations as a single transaction. Create the
- * operation instances via {@link CuratorFramework#transactionOp()}
- *
- * @param operations operations that make up the transaction.
- * @return result details for foreground operations or <code>null</code> for background operations
- */
- CompletionStage<List<CuratorTransactionResult>> forOperations(List<CuratorOp> operations);
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
deleted file mode 100644
index 300b695..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.crimps.async;
-
-public interface CrimpedPathable<T>
-{
- /**
- * Commit the currently building operation using the given path
- *
- * @param path the path
- * @return result
- */
- T forPath(String path);
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleable.java
deleted file mode 100644
index be0cc58..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleable.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.api.Statable;
-import java.util.concurrent.CompletionStage;
-
-public interface CrimpedWatchedEnsembleable extends
- CrimpedConfigEnsembleable<Crimped<byte[]>>,
- Statable<CrimpedConfigEnsembleable<Crimped<byte[]>>>,
- CrimpledEnsembleable<Crimped<byte[]>>
-{
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleableImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleableImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleableImpl.java
deleted file mode 100644
index 78c7304..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatchedEnsembleableImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.api.ConfigureEnsembleable;
-import org.apache.curator.framework.api.Ensembleable;
-import org.apache.curator.framework.api.Statable;
-import org.apache.zookeeper.data.Stat;
-
-class CrimpedWatchedEnsembleableImpl implements CrimpedWatchedEnsembleable
-{
- private final CrimpedBackgroundCallback<byte[]> callback;
- private final Statable<ConfigureEnsembleable> configBuilder;
- private Ensembleable<byte[]> ensembleable;
- private ConfigureEnsembleable configureEnsembleable;
-
- CrimpedWatchedEnsembleableImpl(Statable<ConfigureEnsembleable> configBuilder, CrimpedBackgroundCallback<byte[]> callback)
- {
- this.configBuilder = configBuilder;
- this.callback = callback;
- configureEnsembleable = configBuilder.storingStatIn(new Stat());
- ensembleable = configureEnsembleable;
- }
-
- CrimpedWatchedEnsembleableImpl(Ensembleable<byte[]> ensembleable, CrimpedBackgroundCallback<byte[]> callback)
- {
- this.ensembleable = ensembleable;
- this.configBuilder = null;
- this.callback = callback;
- configureEnsembleable = null;
- }
-
- @Override
- public Crimped<byte[]> forEnsemble()
- {
- try
- {
- ensembleable.forEnsemble();
- }
- catch ( Exception e )
- {
- callback.completeExceptionally(e);
- }
- return callback;
- }
-
- @Override
- public CrimpedConfigEnsembleable<Crimped<byte[]>> storingStatIn(Stat stat)
- {
- ensembleable = configureEnsembleable = configBuilder.storingStatIn(stat);
- return this;
- }
-
- @Override
- public CrimpledEnsembleable<Crimped<byte[]>> fromConfig(long config)
- {
- try
- {
- ensembleable = configureEnsembleable.fromConfig(config);
- }
- catch ( Exception e )
- {
- callback.completeExceptionally(e);
- }
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatcher.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatcher.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatcher.java
deleted file mode 100644
index 964a00c..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedWatcher.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import java.util.concurrent.CompletableFuture;
-
-class CrimpedWatcher extends CompletableFuture<WatchedEvent> implements Watcher
-{
- @Override
- public void process(WatchedEvent event)
- {
- switch ( event.getState() )
- {
- case ConnectedReadOnly:
- case SyncConnected:
- case SaslAuthenticated:
- {
- complete(event);
- break;
- }
-
- case Disconnected:
- {
- completeExceptionally(KeeperException.create(KeeperException.Code.CONNECTIONLOSS));
- break;
- }
-
- case AuthFailed:
- {
- completeExceptionally(KeeperException.create(KeeperException.Code.AUTHFAILED));
- break;
- }
-
- case Expired:
- {
- completeExceptionally(KeeperException.create(KeeperException.Code.SESSIONEXPIRED));
- break;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledEnsembleable.java
deleted file mode 100644
index f23349e..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledEnsembleable.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.crimps.async;
-
-public interface CrimpledEnsembleable<T> {
-
- T forEnsemble();
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesable.java
deleted file mode 100644
index 5e03815..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.crimps.async;
-
-public interface CrimpledPathAndBytesable<T> extends CrimpedPathable<T>
-{
- /**
- * Commit the currently building operation using the given path and data
- *
- * @param path the path
- * @param data the data
- * @return result
- */
- T forPath(String path, byte[] data);
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesableImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesableImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesableImpl.java
deleted file mode 100644
index 329de64..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpledPathAndBytesableImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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.crimps.async;
-
-import org.apache.curator.framework.api.PathAndBytesable;
-import org.apache.curator.framework.api.Pathable;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-
-class CrimpledPathAndBytesableImpl<MAIN, RESULT extends CompletionStage<MAIN>> implements CrimpledPathAndBytesable<RESULT>
-{
- private final Pathable<MAIN> pathable;
- private final PathAndBytesable<MAIN> pathAndBytesable;
- private final RESULT result;
- private final CompletableFuture second;
-
- CrimpledPathAndBytesableImpl(Pathable<MAIN> pathable, RESULT result, CompletableFuture second)
- {
- this.result = result;
- this.second = second;
- this.pathAndBytesable = null;
- this.pathable = pathable;
- }
-
- CrimpledPathAndBytesableImpl(PathAndBytesable<MAIN> pathAndBytesable, RESULT result, CompletableFuture second)
- {
- this.pathAndBytesable = pathAndBytesable;
- this.result = result;
- this.second = second;
- this.pathable = null;
- }
-
- @Override
- public RESULT forPath(String path)
- {
- try
- {
- if ( pathable != null )
- {
- pathable.forPath(path);
- }
- else
- {
- pathAndBytesable.forPath(path);
- }
- }
- catch ( Exception e )
- {
- setException(e);
- }
- return result;
- }
-
- @Override
- public RESULT forPath(String path, byte[] data)
- {
- try
- {
- pathAndBytesable.forPath(path, data);
- }
- catch ( Exception e )
- {
- setException(e);
- }
- return result;
- }
-
- private void setException(Exception e)
- {
- result.toCompletableFuture().completeExceptionally(e);
- if ( second != null )
- {
- second.completeExceptionally(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/DeleteOption.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/DeleteOption.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/DeleteOption.java
new file mode 100644
index 0000000..12d037d
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/DeleteOption.java
@@ -0,0 +1,8 @@
+package org.apache.curator.x.crimps.async;
+
+public enum DeleteOption
+{
+ quietly,
+ deletingChildrenIfNeeded,
+ guaranteed
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/WatchedAsyncCuratorFramework.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/WatchedAsyncCuratorFramework.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/WatchedAsyncCuratorFramework.java
new file mode 100644
index 0000000..59760ab
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/WatchedAsyncCuratorFramework.java
@@ -0,0 +1,63 @@
+/**
+ * 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.crimps.async;
+
+import org.apache.curator.framework.api.ExistsBuilder;
+import org.apache.curator.framework.api.GetConfigBuilder;
+import org.apache.curator.framework.api.GetDataBuilder;
+import org.apache.curator.x.crimps.async.details.Crimped;
+import java.util.List;
+
+/**
+ * Zookeeper framework-style client
+ */
+public interface WatchedAsyncCuratorFramework
+{
+ /**
+ * Start an exists builder
+ * <p>
+ * The builder will return a Stat object as if org.apache.zookeeper.ZooKeeper.exists() were called. Thus, a null
+ * means that it does not exist and an actual Stat object means it does exist.
+ *
+ * @return builder object
+ */
+ ExistsBuilder checkExists();
+
+ /**
+ * Start a get data builder
+ *
+ * @return builder object
+ */
+ GetDataBuilder getData();
+
+ /**
+ * Start a get children builder
+ *
+ * @return builder object
+ */
+ AsyncGetChildrenBuilder<Crimped<List<String>>> getChildren();
+
+ /**
+ * Start a getConfig builder
+ *
+ * @return builder object
+ */
+ GetConfigBuilder getConfig();
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/AsyncCrimps.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/AsyncCrimps.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/AsyncCrimps.java
new file mode 100644
index 0000000..c25ec45
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/AsyncCrimps.java
@@ -0,0 +1,264 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.api.*;
+import org.apache.curator.framework.api.transaction.CuratorMultiTransactionMain;
+import org.apache.curator.framework.api.transaction.CuratorTransactionResult;
+import org.apache.curator.x.crimps.async.AsyncMultiTransaction;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+import java.util.function.Function;
+
+public class AsyncCrimps
+{
+ public static final BackgroundProc<String> nameProc = makeProc(CuratorEvent::getName);
+ public static final BackgroundProc<String> pathProc = makeProc(CuratorEvent::getPath);
+ public static final BackgroundProc<Void> ignoredProc = makeProc(e -> null);
+ public static final BackgroundProc<byte[]> dataProc = makeProc(CuratorEvent::getData);
+ public static final BackgroundProc<Stat> statProc = makeProc(CuratorEvent::getStat);
+ public static final BackgroundProc<Stat> safeStatProc = (event, future) -> {
+ if ( (event.getResultCode() == 0) || (event.getResultCode() == KeeperException.Code.NONODE.intValue()) )
+ {
+ future.complete(event.getStat());
+ }
+ else
+ {
+ future.completeExceptionally(KeeperException.create(KeeperException.Code.get(event.getResultCode()), event.getPath()));
+ }
+ return null;
+ };
+ public static final BackgroundProc<List<String>> childrenProc = makeProc(CuratorEvent::getChildren);
+ public static final BackgroundProc<List<ACL>> aclProc = makeProc(CuratorEvent::getACLList);
+ public static final BackgroundProc<List<CuratorTransactionResult>> opResultsProc = makeProc(CuratorEvent::getOpResults);
+
+ private final UnhandledErrorListener unhandledErrorListener;
+
+ public static <T> BackgroundProc<T> makeProc(Function<CuratorEvent, T> proc)
+ {
+ return (event, future) -> {
+ if ( event.getResultCode() == 0 )
+ {
+ future.complete(proc.apply(event));
+ }
+ else
+ {
+ future.completeExceptionally(KeeperException.create(KeeperException.Code.get(event.getResultCode()), event.getPath()));
+ }
+ return null;
+ };
+ }
+
+ public AsyncCrimps(UnhandledErrorListener unhandledErrorListener)
+ {
+ this.unhandledErrorListener = unhandledErrorListener;
+ }
+
+ public AsyncCrimps withUnhandledErrorListener(UnhandledErrorListener unhandledErrorListener)
+ {
+ return new AsyncCrimps(unhandledErrorListener);
+ }
+
+ public CrimpledPathAndBytesable<CompletionStage<String>> name(BackgroundPathAndBytesable<String> builder)
+ {
+ return build(builder, nameProc);
+ }
+
+ public CrimpledPathAndBytesable<CompletionStage<String>> path(BackgroundPathAndBytesable<String> builder)
+ {
+ return build(builder, pathProc);
+ }
+
+ public CrimpedPathable<CompletionStage<Void>> ignored(BackgroundPathable<Void> builder)
+ {
+ return build(builder, ignoredProc);
+ }
+
+ public CrimpedPathable<CompletionStage<byte[]>> data(BackgroundPathable<byte[]> builder)
+ {
+ return build(builder, dataProc);
+ }
+
+ public CrimpedPathable<Crimped<byte[]>> dataWatched(Watchable<BackgroundPathable<byte[]>> builder)
+ {
+ return build(builder, dataProc);
+ }
+
+ public CrimpedPathable<CompletionStage<List<String>>> children(BackgroundPathable<List<String>> builder)
+ {
+ return build(builder, childrenProc);
+ }
+
+ public CrimpedPathable<Crimped<List<String>>> childrenWatched(Watchable<BackgroundPathable<List<String>>> builder)
+ {
+ return build(builder, childrenProc);
+ }
+
+ public CrimpedPathable<CompletionStage<Stat>> stat(BackgroundPathable<Stat> builder)
+ {
+ return build(builder, safeStatProc);
+ }
+
+ public CrimpledPathAndBytesable<CompletionStage<Stat>> stat(BackgroundPathAndBytesable<Stat> builder)
+ {
+ return build(builder, statProc);
+ }
+
+ public CrimpedPathable<Crimped<Stat>> statWatched(Watchable<BackgroundPathable<Stat>> builder)
+ {
+ return build(builder, safeStatProc);
+ }
+
+ public CrimpedPathable<CompletionStage<List<ACL>>> acls(BackgroundPathable<List<ACL>> builder)
+ {
+ return build(builder, aclProc);
+ }
+
+ public CrimpledPathAndBytesable<CompletionStage<Stat>> statBytes(BackgroundPathAndBytesable<Stat> builder)
+ {
+ return build(builder, statProc);
+ }
+
+ public CrimpedWatchedEnsembleable ensembleWatched(Watchable<BackgroundEnsembleable<byte[]>> builder)
+ {
+ CrimpedWatcher crimpedWatcher = new CrimpedWatcher();
+ CrimpedBackgroundCallback<byte[]> callback = new CrimpedBackgroundCallback<>(dataProc, crimpedWatcher);
+ BackgroundEnsembleable<byte[]> localBuilder = builder.usingWatcher(crimpedWatcher);
+ return new CrimpedWatchedEnsembleableImpl(toFinalBuilder(callback, localBuilder), callback);
+ }
+
+ public CrimpedEnsembleable ensemble(Backgroundable<ErrorListenerEnsembleable<byte[]>> builder)
+ {
+ CrimpedBackgroundCallback<byte[]> callback = new CrimpedBackgroundCallback<>(dataProc, null);
+ return new CrimpedEnsembleableImpl(toFinalBuilder(callback, builder), callback);
+ }
+
+ public CrimpedEnsembleable ensemble(Backgroundable<ErrorListenerReconfigBuilderMain> builder, List<String> newMembers)
+ {
+ CrimpedBackgroundCallback<byte[]> callback = new CrimpedBackgroundCallback<>(dataProc, null);
+
+ ReconfigBuilderMain main;
+ if ( unhandledErrorListener != null )
+ {
+ main = builder.inBackground(callback).withUnhandledErrorListener(unhandledErrorListener);
+ }
+ else
+ {
+ main = builder.inBackground(callback);
+ }
+
+ return new CrimpedEnsembleableImpl((Statable<ConfigureEnsembleable>)main.withNewMembers(newMembers), callback);
+ }
+
+ public CrimpedEnsembleable ensemble(Backgroundable<ErrorListenerReconfigBuilderMain> builder, List<String> joining, List<String> leaving)
+ {
+ CrimpedBackgroundCallback<byte[]> callback = new CrimpedBackgroundCallback<>(dataProc, null);
+
+ ReconfigBuilderMain main;
+ if ( unhandledErrorListener != null )
+ {
+ main = builder.inBackground(callback).withUnhandledErrorListener(unhandledErrorListener);
+ }
+ else
+ {
+ main = builder.inBackground(callback);
+ }
+
+ Statable<ConfigureEnsembleable> configBuilder;
+ if ( nonEmpty(joining) && nonEmpty(leaving) )
+ {
+ configBuilder = main.joining(joining).leaving(leaving);
+ }
+ else if ( nonEmpty(joining) )
+ {
+ configBuilder = main.joining(joining);
+ }
+ else if ( nonEmpty(leaving) )
+ {
+ configBuilder = main.leaving(leaving);
+ }
+ else
+ {
+ throw new IllegalArgumentException("leaving and joining cannot both be empty");
+ }
+
+ return new CrimpedEnsembleableImpl(configBuilder, callback);
+ }
+
+ public AsyncMultiTransaction opResults(Backgroundable<ErrorListenerMultiTransactionMain> builder)
+ {
+ CrimpedBackgroundCallback<List<CuratorTransactionResult>> callback = new CrimpedBackgroundCallback<>(opResultsProc, null);
+ ErrorListenerMultiTransactionMain main = builder.inBackground(callback);
+ CuratorMultiTransactionMain finalBuilder = (unhandledErrorListener != null) ? main.withUnhandledErrorListener(unhandledErrorListener) : main;
+ return ops -> {
+ try
+ {
+ finalBuilder.forOperations(ops);
+ }
+ catch ( Exception e )
+ {
+ callback.completeExceptionally(e);
+ }
+ return callback;
+ };
+ }
+
+ public <T> CrimpledPathAndBytesable<CompletionStage<T>> build(BackgroundPathAndBytesable<T> builder, BackgroundProc<T> backgroundProc)
+ {
+ CrimpedBackgroundCallback<T> callback = new CrimpedBackgroundCallback<T>(backgroundProc, null);
+ ErrorListenerPathAndBytesable<T> localBuilder = builder.inBackground(callback);
+ PathAndBytesable<T> finalLocalBuilder = (unhandledErrorListener != null) ? localBuilder.withUnhandledErrorListener(unhandledErrorListener) : localBuilder;
+ return new CrimpledPathAndBytesableImpl<>(finalLocalBuilder, callback, null);
+ }
+
+ public <T> CrimpedPathable<Crimped<T>> build(Watchable<BackgroundPathable<T>> builder, BackgroundProc<T> backgroundProc)
+ {
+ CrimpedWatcher crimpedWatcher = new CrimpedWatcher();
+ CrimpedBackgroundCallback<T> callback = new CrimpedBackgroundCallback<>(backgroundProc, crimpedWatcher);
+ Pathable<T> finalLocalBuilder = toFinalBuilder(callback, builder.usingWatcher(crimpedWatcher));
+ return new CrimpledPathAndBytesableImpl<T, Crimped<T>>(finalLocalBuilder, callback, crimpedWatcher);
+ }
+
+ public <T> CrimpedPathable<CompletionStage<T>> build(BackgroundPathable<T> builder, BackgroundProc<T> backgroundProc)
+ {
+ CrimpedBackgroundCallback<T> callback = new CrimpedBackgroundCallback<T>(backgroundProc, null);
+ Pathable<T> finalLocalBuilder = toFinalBuilder(callback, builder);
+ return new CrimpledPathAndBytesableImpl<>(finalLocalBuilder, callback, null);
+ }
+
+ private Ensembleable<byte[]> toFinalBuilder(CrimpedBackgroundCallback<byte[]> callback, Backgroundable<ErrorListenerEnsembleable<byte[]>> builder)
+ {
+ ErrorListenerEnsembleable<byte[]> localBuilder = builder.inBackground(callback);
+ return (unhandledErrorListener != null) ? localBuilder.withUnhandledErrorListener(unhandledErrorListener) : localBuilder;
+ }
+
+ private <T> Pathable<T> toFinalBuilder(CrimpedBackgroundCallback<T> callback, BackgroundPathable<T> builder)
+ {
+ ErrorListenerPathable<T> localBuilder = builder.inBackground(callback);
+ return (unhandledErrorListener != null) ? localBuilder.withUnhandledErrorListener(unhandledErrorListener) : localBuilder;
+ }
+
+ private static boolean nonEmpty(List<String> list)
+ {
+ return (list != null) && !list.isEmpty();
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/BackgroundProc.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/BackgroundProc.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/BackgroundProc.java
new file mode 100644
index 0000000..cd86ec7
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/BackgroundProc.java
@@ -0,0 +1,27 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.api.CuratorEvent;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiFunction;
+
+interface BackgroundProc<T> extends BiFunction<CuratorEvent, CompletableFuture<T>, Void>
+{
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/Crimped.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/Crimped.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/Crimped.java
new file mode 100644
index 0000000..7ab77b1
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/Crimped.java
@@ -0,0 +1,27 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.zookeeper.WatchedEvent;
+import java.util.concurrent.CompletionStage;
+
+public interface Crimped<T> extends CompletionStage<T>
+{
+ CompletionStage<WatchedEvent> event();
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedBackgroundCallback.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedBackgroundCallback.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedBackgroundCallback.java
new file mode 100644
index 0000000..074b746
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedBackgroundCallback.java
@@ -0,0 +1,50 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.BackgroundCallback;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.zookeeper.WatchedEvent;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+class CrimpedBackgroundCallback<T> extends CompletableFuture<T> implements BackgroundCallback, Crimped<T>
+{
+ private final BackgroundProc<T> resultFunction;
+ private final CrimpedWatcher watcher;
+
+ CrimpedBackgroundCallback(BackgroundProc<T> resultFunction, CrimpedWatcher watcher)
+ {
+ this.resultFunction = resultFunction;
+ this.watcher = watcher;
+ }
+
+ @Override
+ public CompletionStage<WatchedEvent> event()
+ {
+ return watcher;
+ }
+
+ @Override
+ public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
+ {
+ resultFunction.apply(event, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedConfigEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedConfigEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedConfigEnsembleable.java
new file mode 100644
index 0000000..6cc3d12
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedConfigEnsembleable.java
@@ -0,0 +1,30 @@
+/**
+ * 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.crimps.async.details;
+
+public interface CrimpedConfigEnsembleable<T> extends
+ CrimpledEnsembleable<T>
+{
+ /**
+ * Sets the configuration version to use.
+ * @param config The version of the configuration.
+ * @return this
+ */
+ CrimpledEnsembleable<T> fromConfig(long config);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleable.java
new file mode 100644
index 0000000..942788e
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleable.java
@@ -0,0 +1,29 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.api.Statable;
+import java.util.concurrent.CompletionStage;
+
+public interface CrimpedEnsembleable extends
+ CrimpedConfigEnsembleable<CompletionStage<byte[]>>,
+ Statable<CrimpedConfigEnsembleable<CompletionStage<byte[]>>>,
+ CrimpledEnsembleable<CompletionStage<byte[]>>
+{
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleableImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleableImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleableImpl.java
new file mode 100644
index 0000000..b17468b
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedEnsembleableImpl.java
@@ -0,0 +1,84 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.api.ConfigureEnsembleable;
+import org.apache.curator.framework.api.Ensembleable;
+import org.apache.curator.framework.api.Statable;
+import org.apache.zookeeper.data.Stat;
+import java.util.concurrent.CompletionStage;
+
+class CrimpedEnsembleableImpl implements CrimpedEnsembleable
+{
+ private final CrimpedBackgroundCallback<byte[]> callback;
+ private final Statable<ConfigureEnsembleable> configBuilder;
+ private Ensembleable<byte[]> ensembleable;
+ private ConfigureEnsembleable configureEnsembleable;
+
+ CrimpedEnsembleableImpl(Statable<ConfigureEnsembleable> configBuilder, CrimpedBackgroundCallback<byte[]> callback)
+ {
+ this.configBuilder = configBuilder;
+ this.callback = callback;
+ configureEnsembleable = configBuilder.storingStatIn(new Stat());
+ ensembleable = configureEnsembleable;
+ }
+
+ CrimpedEnsembleableImpl(Ensembleable<byte[]> ensembleable, CrimpedBackgroundCallback<byte[]> callback)
+ {
+ this.ensembleable = ensembleable;
+ this.configBuilder = null;
+ this.callback = callback;
+ configureEnsembleable = null;
+ }
+
+ @Override
+ public CompletionStage<byte[]> forEnsemble()
+ {
+ try
+ {
+ ensembleable.forEnsemble();
+ }
+ catch ( Exception e )
+ {
+ callback.completeExceptionally(e);
+ }
+ return callback;
+ }
+
+ @Override
+ public CrimpedConfigEnsembleable<CompletionStage<byte[]>> storingStatIn(Stat stat)
+ {
+ ensembleable = configureEnsembleable = configBuilder.storingStatIn(stat);
+ return this;
+ }
+
+ @Override
+ public CrimpledEnsembleable<CompletionStage<byte[]>> fromConfig(long config)
+ {
+ try
+ {
+ ensembleable = configureEnsembleable.fromConfig(config);
+ }
+ catch ( Exception e )
+ {
+ callback.completeExceptionally(e);
+ }
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedPathable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedPathable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedPathable.java
new file mode 100644
index 0000000..7136247
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedPathable.java
@@ -0,0 +1,30 @@
+/**
+ * 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.crimps.async.details;
+
+public interface CrimpedPathable<T>
+{
+ /**
+ * Commit the currently building operation using the given path
+ *
+ * @param path the path
+ * @return result
+ */
+ T forPath(String path);
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleable.java
new file mode 100644
index 0000000..337a0e0
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleable.java
@@ -0,0 +1,28 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.api.Statable;
+
+public interface CrimpedWatchedEnsembleable extends
+ CrimpedConfigEnsembleable<Crimped<byte[]>>,
+ Statable<CrimpedConfigEnsembleable<Crimped<byte[]>>>,
+ CrimpledEnsembleable<Crimped<byte[]>>
+{
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleableImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleableImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleableImpl.java
new file mode 100644
index 0000000..4cd2ee5
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleableImpl.java
@@ -0,0 +1,83 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.curator.framework.api.ConfigureEnsembleable;
+import org.apache.curator.framework.api.Ensembleable;
+import org.apache.curator.framework.api.Statable;
+import org.apache.zookeeper.data.Stat;
+
+class CrimpedWatchedEnsembleableImpl implements CrimpedWatchedEnsembleable
+{
+ private final CrimpedBackgroundCallback<byte[]> callback;
+ private final Statable<ConfigureEnsembleable> configBuilder;
+ private Ensembleable<byte[]> ensembleable;
+ private ConfigureEnsembleable configureEnsembleable;
+
+ CrimpedWatchedEnsembleableImpl(Statable<ConfigureEnsembleable> configBuilder, CrimpedBackgroundCallback<byte[]> callback)
+ {
+ this.configBuilder = configBuilder;
+ this.callback = callback;
+ configureEnsembleable = configBuilder.storingStatIn(new Stat());
+ ensembleable = configureEnsembleable;
+ }
+
+ CrimpedWatchedEnsembleableImpl(Ensembleable<byte[]> ensembleable, CrimpedBackgroundCallback<byte[]> callback)
+ {
+ this.ensembleable = ensembleable;
+ this.configBuilder = null;
+ this.callback = callback;
+ configureEnsembleable = null;
+ }
+
+ @Override
+ public Crimped<byte[]> forEnsemble()
+ {
+ try
+ {
+ ensembleable.forEnsemble();
+ }
+ catch ( Exception e )
+ {
+ callback.completeExceptionally(e);
+ }
+ return callback;
+ }
+
+ @Override
+ public CrimpedConfigEnsembleable<Crimped<byte[]>> storingStatIn(Stat stat)
+ {
+ ensembleable = configureEnsembleable = configBuilder.storingStatIn(stat);
+ return this;
+ }
+
+ @Override
+ public CrimpledEnsembleable<Crimped<byte[]>> fromConfig(long config)
+ {
+ try
+ {
+ ensembleable = configureEnsembleable.fromConfig(config);
+ }
+ catch ( Exception e )
+ {
+ callback.completeExceptionally(e);
+ }
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatcher.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatcher.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatcher.java
new file mode 100644
index 0000000..334c414
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatcher.java
@@ -0,0 +1,60 @@
+/**
+ * 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.crimps.async.details;
+
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import java.util.concurrent.CompletableFuture;
+
+class CrimpedWatcher extends CompletableFuture<WatchedEvent> implements Watcher
+{
+ @Override
+ public void process(WatchedEvent event)
+ {
+ switch ( event.getState() )
+ {
+ case ConnectedReadOnly:
+ case SyncConnected:
+ case SaslAuthenticated:
+ {
+ complete(event);
+ break;
+ }
+
+ case Disconnected:
+ {
+ completeExceptionally(KeeperException.create(KeeperException.Code.CONNECTIONLOSS));
+ break;
+ }
+
+ case AuthFailed:
+ {
+ completeExceptionally(KeeperException.create(KeeperException.Code.AUTHFAILED));
+ break;
+ }
+
+ case Expired:
+ {
+ completeExceptionally(KeeperException.create(KeeperException.Code.SESSIONEXPIRED));
+ break;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledEnsembleable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledEnsembleable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledEnsembleable.java
new file mode 100644
index 0000000..1ea93a9
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledEnsembleable.java
@@ -0,0 +1,24 @@
+/**
+ * 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.crimps.async.details;
+
+public interface CrimpledEnsembleable<T> {
+
+ T forEnsemble();
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/9b84ba39/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesable.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesable.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesable.java
new file mode 100644
index 0000000..511ee72
--- /dev/null
+++ b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesable.java
@@ -0,0 +1,32 @@
+/**
+ * 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.crimps.async.details;
+
+public interface CrimpledPathAndBytesable<T> extends CrimpedPathable<T>
+{
+ /**
+ * Commit the currently building operation using the given path and data
+ *
+ * @param path the path
+ * @param data the data
+ * @return result
+ */
+ T forPath(String path, byte[] data);
+}