use of org.opendaylight.controller.cluster.datastore.messages.AddPrefixShardReplica in project controller by opendaylight.
the class ClusterAdminRpcService method addPrefixShardReplica.
@Override
public Future<RpcResult<Void>> addPrefixShardReplica(final AddPrefixShardReplicaInput input) {
final InstanceIdentifier<?> identifier = input.getShardPrefix();
if (identifier == null) {
return newFailedRpcResultFuture("A valid shard identifier must be specified");
}
final DataStoreType dataStoreType = input.getDataStoreType();
if (dataStoreType == null) {
return newFailedRpcResultFuture("A valid DataStoreType must be specified");
}
LOG.info("Adding replica for shard {}, datastore type {}", identifier, dataStoreType);
final YangInstanceIdentifier prefix = serializer.toYangInstanceIdentifier(identifier);
final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, new AddPrefixShardReplica(prefix));
Futures.addCallback(future, new FutureCallback<Success>() {
@Override
public void onSuccess(Success success) {
LOG.info("Successfully added replica for shard {}", prefix);
returnFuture.set(newSuccessfulResult());
}
@Override
public void onFailure(Throwable failure) {
onMessageFailure(String.format("Failed to add replica for shard %s", prefix), returnFuture, failure);
}
}, MoreExecutors.directExecutor());
return returnFuture;
}
Aggregations