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.CreatePrefixShardOutput;
+import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CreatePrefixShardOutputBuilder;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemovePrefixShardInput;
+import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemovePrefixShardOutput;
+import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemovePrefixShardOutputBuilder;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
this.serializer = serializer;
}
- public ListenableFuture<RpcResult<Void>> onCreatePrefixShard(final CreatePrefixShardInput input) {
+ public ListenableFuture<RpcResult<CreatePrefixShardOutput>> onCreatePrefixShard(
+ final CreatePrefixShardInput input) {
- final SettableFuture<RpcResult<Void>> future = SettableFuture.create();
+ final SettableFuture<RpcResult<CreatePrefixShardOutput>> future = SettableFuture.create();
final CompletionStage<DistributedShardRegistration> completionStage;
final YangInstanceIdentifier identifier = serializer.toYangInstanceIdentifier(input.getPrefix());
LOG.debug("Shard[{}] created successfully.", identifier);
registrations.put(identifier, registration);
- final ListenableFuture<Void> ensureFuture = ensureListExists();
- Futures.addCallback(ensureFuture, new FutureCallback<Void>() {
+ final ListenableFuture<?> ensureFuture = ensureListExists();
+ Futures.addCallback(ensureFuture, new FutureCallback<Object>() {
@Override
- public void onSuccess(@Nullable final Void result) {
+ public void onSuccess(@Nullable final Object result) {
LOG.debug("Initial list write successful.");
- future.set(RpcResultBuilder.<Void>success().build());
+ future.set(RpcResultBuilder.success(new CreatePrefixShardOutputBuilder().build()).build());
}
@Override
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());
+ future.set(RpcResultBuilder.<CreatePrefixShardOutput>failed().withRpcError(error).build());
}
}, MoreExecutors.directExecutor());
});
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());
+ future.set(RpcResultBuilder.<CreatePrefixShardOutput>failed().withRpcError(error).build());
return null;
});
} catch (final DOMDataTreeShardingConflictException e) {
final RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "create-shard-failed",
"Sharding conflict", "cluster-test-app", "", e);
- future.set(RpcResultBuilder.<Void>failed().withRpcError(error).build());
+ future.set(RpcResultBuilder.<CreatePrefixShardOutput>failed().withRpcError(error).build());
}
return future;
}
- public ListenableFuture<RpcResult<Void>> onRemovePrefixShard(final RemovePrefixShardInput input) {
+ public ListenableFuture<RpcResult<RemovePrefixShardOutput>> onRemovePrefixShard(
+ final RemovePrefixShardInput input) {
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.");
- return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
+ return Futures.immediateFuture(RpcResultBuilder.<RemovePrefixShardOutput>failed().withRpcError(error)
+ .build());
}
- final SettableFuture<RpcResult<Void>> future = SettableFuture.create();
+ final SettableFuture<RpcResult<RemovePrefixShardOutput>> future = SettableFuture.create();
final CompletionStage<Void> close = registration.close();
- close.thenRun(() -> future.set(RpcResultBuilder.<Void>success().build()));
+ close.thenRun(() -> future.set(RpcResultBuilder.success(new RemovePrefixShardOutputBuilder().build()).build()));
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);
- future.set(RpcResultBuilder.<Void>failed().withRpcError(error).build());
+ future.set(RpcResultBuilder.<RemovePrefixShardOutput>failed().withRpcError(error).build());
return null;
});
return future;
}
- private ListenableFuture<Void> ensureListExists() {
+ private ListenableFuture<?> ensureListExists() {
final CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder = ImmutableNodes.mapNodeBuilder(ID_INT);
cursor.merge(containerNode.getIdentifier(), containerNode);
cursor.close();
- final ListenableFuture<Void> future = tx.submit();
- Futures.addCallback(future, new FutureCallback<Void>() {
+ final ListenableFuture<?> future = tx.commit();
+ Futures.addCallback(future, new FutureCallback<Object>() {
@Override
- public void onSuccess(@Nullable final Void result) {
+ public void onSuccess(@Nullable final Object result) {
try {
LOG.debug("Closing producer for initial list.");
producer.close();