* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-import static org.opendaylight.controller.clustering.it.provider.impl.ProduceTransactionsHandler.ID;
-import static org.opendaylight.controller.clustering.it.provider.impl.ProduceTransactionsHandler.ID_INT;
-import static org.opendaylight.controller.clustering.it.provider.impl.ProduceTransactionsHandler.ID_INTS;
-import static org.opendaylight.controller.clustering.it.provider.impl.ProduceTransactionsHandler.ITEM;
+import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ID;
+import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ID_INT;
+import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ID_INTS;
+import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ITEM;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletionStage;
import java.util.stream.Collectors;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletionStage;
import java.util.stream.Collectors;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.sharding.DistributedShardFactory;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.sharding.DistributedShardFactory;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CreatePrefixShardInput;
import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CreatePrefixShardInput;
-import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ProduceTransactionsOutput;
+import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CreatePrefixShardOutput;
+import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CreatePrefixShardOutputBuilder;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
final CompletionStage<DistributedShardRegistration> completionStage;
final YangInstanceIdentifier identifier = serializer.toYangInstanceIdentifier(input.getPrefix());
try {
final CompletionStage<DistributedShardRegistration> completionStage;
final YangInstanceIdentifier identifier = serializer.toYangInstanceIdentifier(input.getPrefix());
try {
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, identifier),
input.getReplicas().stream().map(MemberName::forName).collect(Collectors.toList()));
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, identifier),
input.getReplicas().stream().map(MemberName::forName).collect(Collectors.toList()));
LOG.debug("Shard[{}] created successfully.", identifier);
registrations.put(identifier, registration);
LOG.debug("Shard[{}] created successfully.", identifier);
registrations.put(identifier, registration);
- final CheckedFuture<Void, TransactionCommitFailedException> ensureFuture = ensureListExists();
- Futures.addCallback(ensureFuture, new FutureCallback<Void>() {
+ final ListenableFuture<?> ensureFuture = ensureListExists();
+ Futures.addCallback(ensureFuture, new FutureCallback<Object>() {
- final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
- "Shard creation failed", "cluster-test-app", "", throwable);
- future.set(RpcResultBuilder.<Void>failed().withRpcError(error).build());
+ final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION,
+ "create-shard-failed", "Shard creation failed", "cluster-test-app", "", throwable);
+ future.set(RpcResultBuilder.<CreatePrefixShardOutput>failed().withRpcError(error).build());
});
completionStage.exceptionally(throwable -> {
LOG.warn("Shard[{}] creation failed:", identifier, throwable);
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
"Shard creation failed", "cluster-test-app", "", throwable);
});
completionStage.exceptionally(throwable -> {
LOG.warn("Shard[{}] creation failed:", identifier, throwable);
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
"Shard creation failed", "cluster-test-app", "", throwable);
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
"Sharding conflict", "cluster-test-app", "", e);
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
"Sharding conflict", "cluster-test-app", "", e);
final YangInstanceIdentifier identifier = serializer.toYangInstanceIdentifier(input.getPrefix());
final DistributedShardRegistration registration = registrations.get(identifier);
final YangInstanceIdentifier identifier = serializer.toYangInstanceIdentifier(input.getPrefix());
final DistributedShardRegistration registration = registrations.get(identifier);
if (registration == null) {
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "registration-missing",
"No shard registered at this prefix.");
if (registration == null) {
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "registration-missing",
"No shard registered at this prefix.");
close.exceptionally(throwable -> {
LOG.warn("Shard[{}] removal failed:", identifier, throwable);
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "remove-shard-failed",
"Shard removal failed", "cluster-test-app", "", throwable);
close.exceptionally(throwable -> {
LOG.warn("Shard[{}] removal failed:", identifier, throwable);
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "remove-shard-failed",
"Shard removal failed", "cluster-test-app", "", throwable);
final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false);
final DOMDataTreeWriteCursor cursor =
tx.createCursor(new DOMDataTreeIdentifier(
final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false);
final DOMDataTreeWriteCursor cursor =
tx.createCursor(new DOMDataTreeIdentifier(
- final CheckedFuture<Void, TransactionCommitFailedException> future = tx.submit();
- Futures.addCallback(future, new FutureCallback<Void>() {
+ final ListenableFuture<?> future = tx.commit();
+ Futures.addCallback(future, new FutureCallback<Object>() {