Search in sources :

Example 1 with AddPrefixShardReplicaInput

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

the class ClusterAdminRpcServiceTest method addPrefixShardReplica.

private void addPrefixShardReplica(final MemberNode memberNode, final InstanceIdentifier<?> identifier, final BindingNormalizedNodeSerializer serializer, final String shardName, final String... peerMemberNames) throws Exception {
    final AddPrefixShardReplicaInput input = new AddPrefixShardReplicaInputBuilder().setShardPrefix(identifier).setDataStoreType(DataStoreType.Config).build();
    final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), serializer);
    final RpcResult<Void> rpcResult = service.addPrefixShardReplica(input).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyRaftPeersPresent(memberNode.configDataStore(), shardName, peerMemberNames);
    Optional<ActorRef> optional = memberNode.configDataStore().getActorContext().findLocalShard(shardName);
    assertTrue("Replica shard not present", optional.isPresent());
}
Also used : AddPrefixShardReplicaInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddPrefixShardReplicaInput) AddPrefixShardReplicaInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddPrefixShardReplicaInputBuilder) ActorRef(akka.actor.ActorRef)

Example 2 with AddPrefixShardReplicaInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddPrefixShardReplicaInput 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

ActorRef (akka.actor.ActorRef)1 Success (akka.actor.Status.Success)1 AddPrefixShardReplica (org.opendaylight.controller.cluster.datastore.messages.AddPrefixShardReplica)1 AddPrefixShardReplicaInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddPrefixShardReplicaInput)1 AddPrefixShardReplicaInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddPrefixShardReplicaInputBuilder)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