Search in sources :

Example 1 with AddShardReplicaInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddShardReplicaInput in project controller by opendaylight.

the class ClusterAdminRpcService method addShardReplica.

@Override
public Future<RpcResult<Void>> addShardReplica(final AddShardReplicaInput input) {
    final String shardName = input.getShardName();
    if (Strings.isNullOrEmpty(shardName)) {
        return newFailedRpcResultFuture("A valid shard name must be specified");
    }
    DataStoreType dataStoreType = input.getDataStoreType();
    if (dataStoreType == null) {
        return newFailedRpcResultFuture("A valid DataStoreType must be specified");
    }
    LOG.info("Adding replica for shard {}", shardName);
    final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
    ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, new AddShardReplica(shardName));
    Futures.addCallback(future, new FutureCallback<Success>() {

        @Override
        public void onSuccess(Success success) {
            LOG.info("Successfully added replica for shard {}", shardName);
            returnFuture.set(newSuccessfulResult());
        }

        @Override
        public void onFailure(Throwable failure) {
            onMessageFailure(String.format("Failed to add replica for shard %s", shardName), returnFuture, failure);
        }
    }, MoreExecutors.directExecutor());
    return returnFuture;
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddShardReplica(org.opendaylight.controller.cluster.datastore.messages.AddShardReplica) Success(akka.actor.Status.Success) DataStoreType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)

Aggregations

Success (akka.actor.Status.Success)1 AddShardReplica (org.opendaylight.controller.cluster.datastore.messages.AddShardReplica)1 DataStoreType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1