Search in sources :

Example 1 with GetShardRoleReply

use of org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply in project controller by opendaylight.

the class ShardManager method onGetShardRole.

private void onGetShardRole(final GetShardRole message) {
    LOG.debug("{}: onGetShardRole for shard: {}", persistenceId(), message.getName());
    final String name = message.getName();
    final ShardInformation shardInformation = localShards.get(name);
    if (shardInformation == null) {
        LOG.info("{}: no shard information for {} found", persistenceId(), name);
        getSender().tell(new Status.Failure(new IllegalArgumentException("Shard with name " + name + " not present.")), ActorRef.noSender());
        return;
    }
    getSender().tell(new GetShardRoleReply(shardInformation.getRole()), ActorRef.noSender());
}
Also used : FollowerInitialSyncUpStatus(org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus) ChangeShardMembersVotingStatus(org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus) FlipShardMembersVotingStatus(org.opendaylight.controller.cluster.datastore.messages.FlipShardMembersVotingStatus) Status(akka.actor.Status) ServerChangeStatus(org.opendaylight.controller.cluster.raft.messages.ServerChangeStatus) ChangeServersVotingStatus(org.opendaylight.controller.cluster.raft.messages.ChangeServersVotingStatus) GetShardRoleReply(org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply)

Example 2 with GetShardRoleReply

use of org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply in project controller by opendaylight.

the class ClusterAdminRpcService method getShardRole.

@Override
public Future<RpcResult<GetShardRoleOutput>> getShardRole(final GetShardRoleInput 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");
    }
    LOG.info("Getting role for shard {}, datastore type {}", shardName, dataStoreType);
    final SettableFuture<RpcResult<GetShardRoleOutput>> returnFuture = SettableFuture.create();
    ListenableFuture<GetShardRoleReply> future = sendMessageToShardManager(dataStoreType, new GetShardRole(shardName));
    Futures.addCallback(future, new FutureCallback<GetShardRoleReply>() {

        @Override
        public void onSuccess(final GetShardRoleReply reply) {
            if (reply == null) {
                returnFuture.set(ClusterAdminRpcService.<GetShardRoleOutput>newFailedRpcResultBuilder("No Shard role present. Please retry..").build());
                return;
            }
            LOG.info("Successfully received role:{} for shard {}", reply.getRole(), shardName);
            final GetShardRoleOutputBuilder builder = new GetShardRoleOutputBuilder();
            if (reply.getRole() != null) {
                builder.setRole(reply.getRole());
            }
            returnFuture.set(newSuccessfulResult(builder.build()));
        }

        @Override
        public void onFailure(final Throwable failure) {
            returnFuture.set(ClusterAdminRpcService.<GetShardRoleOutput>newFailedRpcResultBuilder("Failed to get shard role.", failure).build());
        }
    }, MoreExecutors.directExecutor());
    return returnFuture;
}
Also used : GetShardRole(org.opendaylight.controller.cluster.datastore.messages.GetShardRole) GetShardRoleReply(org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetShardRoleOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetShardRoleOutputBuilder) DataStoreType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)

Example 3 with GetShardRoleReply

use of org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply in project controller by opendaylight.

the class ClusterAdminRpcService method getPrefixShardRole.

@Override
public Future<RpcResult<GetPrefixShardRoleOutput>> getPrefixShardRole(final GetPrefixShardRoleInput 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("Getting prefix shard role for shard: {}, datastore type {}", identifier, dataStoreType);
    final YangInstanceIdentifier prefix = serializer.toYangInstanceIdentifier(identifier);
    final String shardName = ClusterUtils.getCleanShardName(prefix);
    final SettableFuture<RpcResult<GetPrefixShardRoleOutput>> returnFuture = SettableFuture.create();
    ListenableFuture<GetShardRoleReply> future = sendMessageToShardManager(dataStoreType, new GetShardRole(shardName));
    Futures.addCallback(future, new FutureCallback<GetShardRoleReply>() {

        @Override
        public void onSuccess(final GetShardRoleReply reply) {
            if (reply == null) {
                returnFuture.set(ClusterAdminRpcService.<GetPrefixShardRoleOutput>newFailedRpcResultBuilder("No Shard role present. Please retry..").build());
                return;
            }
            LOG.info("Successfully received role:{} for shard {}", reply.getRole(), shardName);
            final GetPrefixShardRoleOutputBuilder builder = new GetPrefixShardRoleOutputBuilder();
            if (reply.getRole() != null) {
                builder.setRole(reply.getRole());
            }
            returnFuture.set(newSuccessfulResult(builder.build()));
        }

        @Override
        public void onFailure(final Throwable failure) {
            returnFuture.set(ClusterAdminRpcService.<GetPrefixShardRoleOutput>newFailedRpcResultBuilder("Failed to get shard role.", failure).build());
        }
    }, MoreExecutors.directExecutor());
    return returnFuture;
}
Also used : GetShardRole(org.opendaylight.controller.cluster.datastore.messages.GetShardRole) GetShardRoleReply(org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) GetPrefixShardRoleOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetPrefixShardRoleOutputBuilder) DataStoreType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)

Aggregations

GetShardRoleReply (org.opendaylight.controller.cluster.datastore.messages.GetShardRoleReply)3 GetShardRole (org.opendaylight.controller.cluster.datastore.messages.GetShardRole)2 DataStoreType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 Status (akka.actor.Status)1 ChangeShardMembersVotingStatus (org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus)1 FlipShardMembersVotingStatus (org.opendaylight.controller.cluster.datastore.messages.FlipShardMembersVotingStatus)1 FollowerInitialSyncUpStatus (org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus)1 ChangeServersVotingStatus (org.opendaylight.controller.cluster.raft.messages.ChangeServersVotingStatus)1 ServerChangeStatus (org.opendaylight.controller.cluster.raft.messages.ServerChangeStatus)1 GetPrefixShardRoleOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetPrefixShardRoleOutputBuilder)1 GetShardRoleOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetShardRoleOutputBuilder)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1