use of akka.actor.Status.Success 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;
}
use of akka.actor.Status.Success in project controller by opendaylight.
the class ClusterAdminRpcService method changeMemberVotingStatesForAllShards.
@Override
public Future<RpcResult<ChangeMemberVotingStatesForAllShardsOutput>> changeMemberVotingStatesForAllShards(final ChangeMemberVotingStatesForAllShardsInput input) {
List<MemberVotingState> memberVotingStates = input.getMemberVotingState();
if (memberVotingStates == null || memberVotingStates.isEmpty()) {
return newFailedRpcResultFuture("No member voting state input was specified");
}
final List<Entry<ListenableFuture<Success>, ShardResultBuilder>> shardResultData = new ArrayList<>();
Function<String, Object> messageSupplier = shardName -> toChangeShardMembersVotingStatus(shardName, memberVotingStates);
LOG.info("Change member voting states for all shards");
sendMessageToManagerForConfiguredShards(DataStoreType.Config, shardResultData, messageSupplier);
sendMessageToManagerForConfiguredShards(DataStoreType.Operational, shardResultData, messageSupplier);
return waitForShardResults(shardResultData, shardResults -> new ChangeMemberVotingStatesForAllShardsOutputBuilder().setShardResult(shardResults).build(), "Failed to change member voting states");
}
use of akka.actor.Status.Success 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;
}
use of akka.actor.Status.Success in project controller by opendaylight.
the class ClusterAdminRpcService method flipMemberVotingStatesForAllShards.
@Override
public Future<RpcResult<FlipMemberVotingStatesForAllShardsOutput>> flipMemberVotingStatesForAllShards() {
final List<Entry<ListenableFuture<Success>, ShardResultBuilder>> shardResultData = new ArrayList<>();
Function<String, Object> messageSupplier = FlipShardMembersVotingStatus::new;
LOG.info("Flip member voting states for all shards");
sendMessageToManagerForConfiguredShards(DataStoreType.Config, shardResultData, messageSupplier);
sendMessageToManagerForConfiguredShards(DataStoreType.Operational, shardResultData, messageSupplier);
return waitForShardResults(shardResultData, shardResults -> new FlipMemberVotingStatesForAllShardsOutputBuilder().setShardResult(shardResults).build(), "Failed to change member voting states");
}
use of akka.actor.Status.Success in project controller by opendaylight.
the class ClusterAdminRpcService method removePrefixShardReplica.
@Override
public Future<RpcResult<Void>> removePrefixShardReplica(final RemovePrefixShardReplicaInput 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");
}
final String memberName = input.getMemberName();
if (Strings.isNullOrEmpty(memberName)) {
return newFailedRpcResultFuture("A valid member name must be specified");
}
LOG.info("Removing replica for shard {} memberName {}, datastoreType {}", identifier, memberName, dataStoreType);
final YangInstanceIdentifier prefix = serializer.toYangInstanceIdentifier(identifier);
final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
final ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, new RemovePrefixShardReplica(prefix, MemberName.forName(memberName)));
Futures.addCallback(future, new FutureCallback<Success>() {
@Override
public void onSuccess(final Success success) {
LOG.info("Successfully removed replica for shard {}", prefix);
returnFuture.set(newSuccessfulResult());
}
@Override
public void onFailure(final Throwable failure) {
onMessageFailure(String.format("Failed to remove replica for shard %s", prefix), returnFuture, failure);
}
}, MoreExecutors.directExecutor());
return returnFuture;
}
Aggregations