Search in sources :

Example 1 with AddPrefixShardReplica

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;
}
Also used : AddPrefixShardReplica(org.opendaylight.controller.cluster.datastore.messages.AddPrefixShardReplica) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) 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 AddPrefixShardReplica (org.opendaylight.controller.cluster.datastore.messages.AddPrefixShardReplica)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 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1