Search in sources :

Example 1 with RemovePrefixShardReplicaInput

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

the class ClusterAdminRpcServiceTest method removePrefixShardReplica.

private void removePrefixShardReplica(final MemberNode memberNode, final InstanceIdentifier<?> identifier, final String removeFromMember, final BindingNormalizedNodeSerializer serializer, final String shardName, final String... peerMemberNames) throws Exception {
    final RemovePrefixShardReplicaInput input = new RemovePrefixShardReplicaInputBuilder().setDataStoreType(DataStoreType.Config).setShardPrefix(identifier).setMemberName(removeFromMember).build();
    final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), serializer);
    final RpcResult<Void> rpcResult = service.removePrefixShardReplica(input).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyRaftPeersPresent(memberNode.configDataStore(), shardName, peerMemberNames);
}
Also used : RemovePrefixShardReplicaInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemovePrefixShardReplicaInputBuilder) RemovePrefixShardReplicaInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemovePrefixShardReplicaInput)

Example 2 with RemovePrefixShardReplicaInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemovePrefixShardReplicaInput 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;
}
Also used : RemovePrefixShardReplica(org.opendaylight.controller.cluster.datastore.messages.RemovePrefixShardReplica) 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 RemovePrefixShardReplica (org.opendaylight.controller.cluster.datastore.messages.RemovePrefixShardReplica)1 DataStoreType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)1 RemovePrefixShardReplicaInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemovePrefixShardReplicaInput)1 RemovePrefixShardReplicaInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemovePrefixShardReplicaInputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1