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:17 UTC
[18/47] curator git commit: Finished first pass, added license, etc.
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/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
deleted file mode 100644
index 5fd74bd..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncSetDataBuilder.java
+++ /dev/null
@@ -1,36 +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.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/394eb900/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
deleted file mode 100644
index 27b2dbd..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncWatchedGetChildrenBuilder.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 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/394eb900/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
deleted file mode 100644
index 12d037d..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/DeleteOption.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.curator.x.crimps.async;
-
-public enum DeleteOption
-{
- quietly,
- deletingChildrenIfNeeded,
- guaranteed
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/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
deleted file mode 100644
index 59760ab..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/WatchedAsyncCuratorFramework.java
+++ /dev/null
@@ -1,63 +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.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/394eb900/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
deleted file mode 100644
index c25ec45..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/AsyncCrimps.java
+++ /dev/null
@@ -1,264 +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.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/394eb900/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
deleted file mode 100644
index cd86ec7..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 7ab77b1..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 074b746..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 6cc3d12..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 942788e..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index b17468b..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 7136247..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 337a0e0..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpedWatchedEnsembleable.java
+++ /dev/null
@@ -1,28 +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.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/394eb900/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
deleted file mode 100644
index 4cd2ee5..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 334c414..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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/394eb900/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
deleted file mode 100644
index 1ea93a9..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.details;
-
-public interface CrimpledEnsembleable<T> {
-
- T forEnsemble();
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/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
deleted file mode 100644
index 511ee72..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.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);
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesableImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesableImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/CrimpledPathAndBytesableImpl.java
deleted file mode 100644
index 22408ea..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/details/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.details;
-
-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/394eb900/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncCuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncCuratorFrameworkImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncCuratorFrameworkImpl.java
deleted file mode 100644
index 74adaf1..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncCuratorFrameworkImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.apache.curator.x.crimps.async.imps;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.*;
-import org.apache.curator.framework.api.transaction.TransactionOp;
-import org.apache.curator.x.crimps.async.AsyncCuratorFramework;
-import org.apache.curator.x.crimps.async.AsyncCuratorFrameworkDsl;
-import org.apache.curator.x.crimps.async.AsyncDeleteBuilder;
-import org.apache.curator.x.crimps.async.AsyncGetChildrenBuilder;
-import org.apache.curator.x.crimps.async.AsyncMultiTransaction;
-import org.apache.curator.x.crimps.async.AsyncSetDataBuilder;
-import org.apache.curator.x.crimps.async.WatchedAsyncCuratorFramework;
-import org.apache.curator.x.crimps.async.details.AsyncCrimps;
-import java.util.List;
-import java.util.concurrent.CompletionStage;
-
-public class AsyncCuratorFrameworkImpl implements AsyncCuratorFramework
-{
- private final CuratorFramework client;
- private final AsyncCrimps async;
- private final UnhandledErrorListener unhandledErrorListener;
-
- public AsyncCuratorFrameworkImpl(CuratorFramework client, AsyncCrimps async, UnhandledErrorListener unhandledErrorListener)
- {
- this.client = client;
- this.async = async;
- this.unhandledErrorListener = unhandledErrorListener;
- }
-
- @Override
- public AsyncCuratorFrameworkDsl withUnhandledErrorListener(UnhandledErrorListener listener)
- {
- return new AsyncCuratorFrameworkImpl(client, async, listener);
- }
-
- @Override
- public CuratorFramework getCuratorFramework()
- {
- return client;
- }
-
- @Override
- public WatchedAsyncCuratorFramework watched()
- {
- return new WatchedAsyncCuratorFrameworkImpl(client, async, unhandledErrorListener);
- }
-
- @Override
- public CreateBuilder create()
- {
- return null;
- }
-
- @Override
- public AsyncDeleteBuilder delete()
- {
- return new AsyncDeleteBuilderImpl(client, async, unhandledErrorListener);
- }
-
- @Override
- public ExistsBuilder checkExists()
- {
- return null;
- }
-
- @Override
- public GetDataBuilder getData()
- {
- return null;
- }
-
- @Override
- public AsyncSetDataBuilder setData()
- {
- return new AsyncSetDataBuilderImpl(client, async, unhandledErrorListener);
- }
-
- @Override
- public AsyncGetChildrenBuilder<CompletionStage<List<String>>> getChildren()
- {
- return new AsyncGetChildrenBuilderImpl<CompletionStage<List<String>>>(client, unhandledErrorListener)
- {
- @Override
- protected CompletionStage<List<String>> finish(BackgroundPathable<List<String>> builder, String path)
- {
- return async.children(builder).forPath(path);
- }
- };
- }
-
- @Override
- public GetACLBuilder getACL()
- {
- return null;
- }
-
- @Override
- public SetACLBuilder setACL()
- {
- return null;
- }
-
- @Override
- public ReconfigBuilder reconfig()
- {
- return null;
- }
-
- @Override
- public GetConfigBuilder getConfig()
- {
- return null;
- }
-
- @Override
- public AsyncMultiTransaction transaction()
- {
- return operations -> async.opResults(client.transaction()).forOperations(operations);
- }
-
- @Override
- public TransactionOp transactionOp()
- {
- return null;
- }
-
- @Override
- public SyncBuilder sync()
- {
- return null;
- }
-
- @Override
- public RemoveWatchesBuilder watches()
- {
- return null;
- }
-
- public UnhandledErrorListener getUnhandledErrorListener()
- {
- return unhandledErrorListener;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncDeleteBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncDeleteBuilderImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncDeleteBuilderImpl.java
deleted file mode 100644
index 783c08f..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncDeleteBuilderImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.curator.x.crimps.async.imps;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.BackgroundPathable;
-import org.apache.curator.framework.api.BackgroundVersionable;
-import org.apache.curator.framework.api.ChildrenDeletable;
-import org.apache.curator.framework.api.DeleteBuilder;
-import org.apache.curator.framework.api.DeleteBuilderMain;
-import org.apache.curator.framework.api.UnhandledErrorListener;
-import org.apache.curator.x.crimps.async.AsyncDeleteBuilder;
-import org.apache.curator.x.crimps.async.AsyncPathable;
-import org.apache.curator.x.crimps.async.DeleteOption;
-import org.apache.curator.x.crimps.async.details.AsyncCrimps;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.CompletionStage;
-
-class AsyncDeleteBuilderImpl implements AsyncDeleteBuilder
-{
- private final CuratorFramework client;
- private final AsyncCrimps async;
- private final UnhandledErrorListener unhandledErrorListener;
- private Set<DeleteOption> options = Collections.emptySet();
- private int version = -1;
-
- public AsyncDeleteBuilderImpl(CuratorFramework client, AsyncCrimps async, UnhandledErrorListener unhandledErrorListener)
- {
- this.client = client;
- this.async = async;
- this.unhandledErrorListener = unhandledErrorListener;
- }
-
- @Override
- public AsyncPathable<CompletionStage<Void>> withOptions(Set<DeleteOption> options)
- {
- this.options = Objects.requireNonNull(options, "options cannot be null");
- return this;
- }
-
- @Override
- public AsyncPathable<CompletionStage<Void>> withOptionsAndVersion(Set<DeleteOption> options, int version)
- {
- this.options = Objects.requireNonNull(options, "options cannot be null");
- this.version = version;
- return this;
- }
-
- @Override
- public AsyncPathable<CompletionStage<Void>> withVersion(int version)
- {
- this.version = version;
- return this;
- }
-
- @Override
- public CompletionStage<Void> forPath(String path)
- {
- DeleteBuilder builder1 = client.delete();
- DeleteBuilderMain builder2 = options.contains(DeleteOption.quietly) ? builder1.quietly() : builder1;
- ChildrenDeletable builder3 = options.contains(DeleteOption.guaranteed) ? builder2.guaranteed() : builder2;
- BackgroundVersionable builder4 = options.contains(DeleteOption.deletingChildrenIfNeeded) ? builder3.deletingChildrenIfNeeded() : builder3;
- BackgroundPathable<Void> builder5 = (version >= 0) ? builder4.withVersion(version) : builder4;
- return async.ignored(builder5).forPath(path);
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncGetChildrenBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncGetChildrenBuilderImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncGetChildrenBuilderImpl.java
deleted file mode 100644
index 67f9e23..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncGetChildrenBuilderImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.curator.x.crimps.async.imps;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.BackgroundPathable;
-import org.apache.curator.framework.api.GetChildrenBuilder;
-import org.apache.curator.framework.api.Pathable;
-import org.apache.curator.framework.api.UnhandledErrorListener;
-import org.apache.curator.framework.api.Watchable;
-import org.apache.curator.x.crimps.async.AsyncGetChildrenBuilder;
-import org.apache.curator.x.crimps.async.AsyncPathable;
-import org.apache.zookeeper.data.Stat;
-import java.util.List;
-
-abstract class AsyncGetChildrenBuilderImpl<T> implements AsyncGetChildrenBuilder<T>
-{
- private final CuratorFramework client;
- private final UnhandledErrorListener unhandledErrorListener;
- private Stat stat;
-
- public AsyncGetChildrenBuilderImpl(CuratorFramework client, UnhandledErrorListener unhandledErrorListener)
- {
- this.client = client;
- this.unhandledErrorListener = unhandledErrorListener;
- }
-
- @Override
- public AsyncPathable<T> storingStatIn(Stat stat)
- {
- this.stat = stat;
- return this;
- }
-
- @Override
- public T forPath(String path)
- {
- GetChildrenBuilder builder1 = client.getChildren();
- Watchable<? extends Pathable<List<String>>> builder2 = (stat != null) ? builder1.storingStatIn(stat) : builder1; // TODO
- return finish(builder1, path);
- }
-
- protected abstract T finish(BackgroundPathable<List<String>> builder, String path);
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncSetDataBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncSetDataBuilderImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncSetDataBuilderImpl.java
deleted file mode 100644
index 906c955..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/AsyncSetDataBuilderImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.apache.curator.x.crimps.async.imps;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.BackgroundPathAndBytesable;
-import org.apache.curator.framework.api.SetDataBuilder;
-import org.apache.curator.framework.api.UnhandledErrorListener;
-import org.apache.curator.x.crimps.async.AsyncPathAndBytesable;
-import org.apache.curator.x.crimps.async.AsyncSetDataBuilder;
-import org.apache.curator.x.crimps.async.details.AsyncCrimps;
-import org.apache.zookeeper.data.Stat;
-import java.util.concurrent.CompletionStage;
-
-class AsyncSetDataBuilderImpl implements AsyncSetDataBuilder
-{
- private final CuratorFramework client;
- private final AsyncCrimps async;
- private final UnhandledErrorListener unhandledErrorListener;
- private boolean compressed = false;
- private int version = -1;
-
- AsyncSetDataBuilderImpl(CuratorFramework client, AsyncCrimps async, UnhandledErrorListener unhandledErrorListener)
- {
- this.client = client;
- this.async = async;
- this.unhandledErrorListener = unhandledErrorListener;
- }
-
- @Override
- public CompletionStage<Stat> forPath(String path)
- {
- return forPath(path, null);
- }
-
- @Override
- public CompletionStage<Stat> forPath(String path, byte[] data)
- {
- SetDataBuilder builder1 = client.setData();
- BackgroundPathAndBytesable<Stat> builder2 = (version >= 0) ? builder1.withVersion(version) : builder1;
- // compressed ? builder2.compressed() : builder2; TODO compressed with version
- if ( data != null )
- {
- return async.stat(builder2).forPath(path, data);
- }
- return async.stat(builder2).forPath(path);
- }
-
- @Override
- public AsyncPathAndBytesable<CompletionStage<Stat>> compressed()
- {
- compressed = true;
- return this;
- }
-
- @Override
- public AsyncPathAndBytesable<CompletionStage<Stat>> compressedWithVersion(int version)
- {
- compressed = true;
- this.version = version;
- return this;
- }
-
- @Override
- public AsyncPathAndBytesable<CompletionStage<Stat>> withVersion(int version)
- {
- this.version = version;
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/WatchedAsyncCuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/WatchedAsyncCuratorFrameworkImpl.java b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/WatchedAsyncCuratorFrameworkImpl.java
deleted file mode 100644
index 9fc5e3c..0000000
--- a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/imps/WatchedAsyncCuratorFrameworkImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.apache.curator.x.crimps.async.imps;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.api.BackgroundPathable;
-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.framework.api.UnhandledErrorListener;
-import org.apache.curator.x.crimps.async.AsyncGetChildrenBuilder;
-import org.apache.curator.x.crimps.async.WatchedAsyncCuratorFramework;
-import org.apache.curator.x.crimps.async.details.AsyncCrimps;
-import org.apache.curator.x.crimps.async.details.Crimped;
-import java.util.List;
-
-public class WatchedAsyncCuratorFrameworkImpl implements WatchedAsyncCuratorFramework
-{
- private final CuratorFramework client;
- private final AsyncCrimps async;
- private final UnhandledErrorListener unhandledErrorListener;
-
- public WatchedAsyncCuratorFrameworkImpl(CuratorFramework client, AsyncCrimps async, UnhandledErrorListener unhandledErrorListener)
- {
- this.client = client;
- this.async = async;
- this.unhandledErrorListener = unhandledErrorListener;
- }
-
- @Override
- public ExistsBuilder checkExists()
- {
- return null;
- }
-
- @Override
- public GetDataBuilder getData()
- {
- return null;
- }
-
- @Override
- public AsyncGetChildrenBuilder<Crimped<List<String>>> getChildren()
- {
- return new AsyncGetChildrenBuilderImpl<Crimped<List<String>>>(client, unhandledErrorListener)
- {
- @Override
- protected Crimped<List<String>> finish(BackgroundPathable<List<String>> builder, String path)
- {
- return null; // TODO
- }
- };
- }
-
- @Override
- public GetConfigBuilder getConfig()
- {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
----------------------------------------------------------------------
diff --git a/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java b/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
deleted file mode 100644
index f7fc930..0000000
--- a/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
+++ /dev/null
@@ -1,258 +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.CuratorFrameworkFactory;
-import org.apache.curator.framework.api.BackgroundPathAndBytesable;
-import org.apache.curator.framework.api.BackgroundPathable;
-import org.apache.curator.framework.api.BackgroundVersionable;
-import org.apache.curator.framework.api.ChildrenDeletable;
-import org.apache.curator.framework.api.DeleteBuilderMain;
-import org.apache.curator.framework.api.SetDataBackgroundVersionable;
-import org.apache.curator.framework.api.SetDataBuilder;
-import org.apache.curator.framework.api.transaction.CuratorOp;
-import org.apache.curator.framework.api.transaction.CuratorTransactionResult;
-import org.apache.curator.framework.api.transaction.OperationType;
-import org.apache.curator.retry.RetryOneTime;
-import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.test.Timing;
-import org.apache.curator.x.crimps.Crimps;
-import org.apache.curator.x.crimps.async.details.AsyncCrimps;
-import org.apache.curator.x.crimps.async.details.Crimped;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-
-public class TestCrimps extends BaseClassForTests
-{
- private final AsyncCrimps async = Crimps.async();
-
- @Test
- public void testCreateAndSet() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
-
- SetDataBuilder setDataBuilder = client.setData();
- BackgroundPathAndBytesable<Stat> withVersion = client.setData().withVersion(0);
- SetDataBackgroundVersionable compressed = client.setData().compressed();
-
- CompletionStage<String> f = async.name(client.create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL)).forPath("/a/b/c");
- complete(f.handle((path, e) -> {
- Assert.assertEquals(path, "/a/b/c0000000000");
- return null;
- }));
-
- f = async.name(client.create()).forPath("/foo/bar");
- assertException(f, KeeperException.Code.NONODE);
-
- CompletionStage<Stat> statFuture = async.statBytes(client.setData()).forPath("/a/b/c0000000000", "hey".getBytes());
- complete(statFuture.handle((stat, e) -> {
- Assert.assertNotNull(stat);
- return null;
- }));
- }
- }
-
- @Test
- public void testDelete() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
- client.create().forPath("/test");
-
- CompletionStage<Void> f = async.ignored(client.delete()).forPath("/test");
- complete(f.handle((v, e) -> {
- Assert.assertEquals(v, null);
- Assert.assertEquals(e, null);
- return null;
- }));
-
- f = async.ignored(client.delete()).forPath("/test");
- assertException(f, KeeperException.Code.NONODE);
- }
- }
-
- @Test
- public void testGetData() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
- client.create().forPath("/test", "foo".getBytes());
-
- CompletionStage<byte[]> f = async.data(client.getData()).forPath("/test");
- complete(f.handle((data, e) -> {
- Assert.assertEquals(data, "foo".getBytes());
- return null;
- }));
- }
- }
-
- @Test
- public void testExists() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
-
- CompletionStage<Stat> f = async.stat(client.checkExists()).forPath("/test");
- complete(f.handle((stat, e) -> {
- Assert.assertNull(e);
- Assert.assertNull(stat);
- return null;
- }));
-
- async.path(client.create()).forPath("/test").toCompletableFuture().get();
- f = async.stat(client.checkExists()).forPath("/test");
- complete(f.handle((stat, e) -> {
- Assert.assertNull(e);
- Assert.assertNotNull(stat);
- return null;
- }));
- }
- }
-
- @Test
- public void testExistsWatched() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
-
- Crimped<Stat> crimped = async.statWatched(client.checkExists().creatingParentContainersIfNeeded()).forPath("/one/two");
- CountDownLatch latch = new CountDownLatch(1);
- crimped.event().handle((event, e) -> {
- Assert.assertNotNull(event);
- latch.countDown();
- return null;
- });
-
- async.path(client.create()).forPath("/one/two");
-
- Assert.assertTrue(new Timing().awaitLatch(latch));
- }
- }
-
- @Test
- public void testReconfig() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
-
- CompletionStage<byte[]> f = async.ensemble(client.reconfig(), Arrays.asList("1", "2"), Arrays.asList("3", "4")).forEnsemble();
- assertException(f, KeeperException.Code.UNIMPLEMENTED);
- }
- }
-
- @Test
- public void testGetConfig() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
-
- CompletionStage<byte[]> f = async.ensemble(client.getConfig()).forEnsemble();
- complete(f.handle((data, e) -> {
- Assert.assertNotNull(data);
- return null;
- }));
- }
- }
-
- @Test
- public void testMulti() throws Exception
- {
- try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) )
- {
- client.start();
-
- CuratorOp createA = client.transactionOp().create().forPath("/a");
- CuratorOp createB = client.transactionOp().create().forPath("/b");
-
- CompletionStage<List<CuratorTransactionResult>> f = async.opResults(client.transaction()).forOperations(Arrays.asList(createA, createB));
- complete(f.handle((ops, e) -> {
- Assert.assertNotNull(ops);
- Assert.assertEquals(ops.get(0).getType(), OperationType.CREATE);
- Assert.assertEquals(ops.get(0).getForPath(), "/a");
- Assert.assertEquals(ops.get(1).getType(), OperationType.CREATE);
- Assert.assertEquals(ops.get(1).getForPath(), "/b");
- return null;
- }));
- }
- }
-
- public void assertException(CompletionStage<?> f, KeeperException.Code code) throws Exception
- {
- complete(f.handle((value, e) -> {
- if ( e == null )
- {
- Assert.fail(code + " expected");
- }
- KeeperException keeperException = unwrap(e);
- Assert.assertNotNull(keeperException);
- Assert.assertEquals(keeperException.code(), code);
- return null;
- }));
- }
-
- private void complete(CompletionStage<?> f) throws Exception
- {
- try
- {
- f.toCompletableFuture().get();
- }
- catch ( InterruptedException e )
- {
- Thread.currentThread().interrupt();
- }
- catch ( ExecutionException e )
- {
- if ( e.getCause() instanceof AssertionError )
- {
- throw ((AssertionError)e.getCause());
- }
- throw e;
- }
- }
-
- private static KeeperException unwrap(Throwable e)
- {
- while ( e != null )
- {
- if ( e instanceof KeeperException )
- {
- return (KeeperException)e;
- }
- e = e.getCause();
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/394eb900/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f96c7c0..832fce1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -286,7 +286,6 @@
<module>curator-x-discovery</module>
<module>curator-x-discovery-server</module>
<module>curator-x-rpc</module>
- <module>curator-x-crimps</module>
<module>curator-x-async</module>
</modules>