Search in sources :

Example 1 with ChangeMemberVotingStatesForShardInput

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

the class ClusterAdminRpcService method changeMemberVotingStatesForShard.

@Override
public Future<RpcResult<Void>> changeMemberVotingStatesForShard(ChangeMemberVotingStatesForShardInput 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");
    }
    List<MemberVotingState> memberVotingStates = input.getMemberVotingState();
    if (memberVotingStates == null || memberVotingStates.isEmpty()) {
        return newFailedRpcResultFuture("No member voting state input was specified");
    }
    ChangeShardMembersVotingStatus changeVotingStatus = toChangeShardMembersVotingStatus(shardName, memberVotingStates);
    LOG.info("Change member voting states for shard {}: {}", shardName, changeVotingStatus.getMeberVotingStatusMap());
    final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
    ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, changeVotingStatus);
    Futures.addCallback(future, new FutureCallback<Success>() {

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

        @Override
        public void onFailure(Throwable failure) {
            onMessageFailure(String.format("Failed to change member voting states for shard %s", shardName), returnFuture, failure);
        }
    }, MoreExecutors.directExecutor());
    return returnFuture;
}
Also used : ChangeShardMembersVotingStatus(org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus) MemberVotingState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingState) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) 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 ChangeShardMembersVotingStatus (org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus)1 DataStoreType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)1 MemberVotingState (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingState)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1