ClusterAdminRpcService implements ClusterAdminService { @Override public ListenableFuture<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; } ClusterAdminRpcService(final DistributedDataStoreInterface configDataStore,
            final DistributedDataStoreInterface operDataStore,
            final BindingNormalizedNodeSerializer serializer); @Override ListenableFuture<RpcResult<AddShardReplicaOutput>> addShardReplica(final AddShardReplicaInput input); @Override ListenableFuture<RpcResult<RemoveShardReplicaOutput>> removeShardReplica(
            final RemoveShardReplicaInput input); @Override ListenableFuture<RpcResult<LocateShardOutput>> locateShard(final LocateShardInput input); @Override ListenableFuture<RpcResult<MakeLeaderLocalOutput>> makeLeaderLocal(final MakeLeaderLocalInput input); @Override ListenableFuture<RpcResult<AddPrefixShardReplicaOutput>> addPrefixShardReplica(
            final AddPrefixShardReplicaInput input); @Override ListenableFuture<RpcResult<RemovePrefixShardReplicaOutput>> removePrefixShardReplica(
            final RemovePrefixShardReplicaInput input); @Override ListenableFuture<RpcResult<AddReplicasForAllShardsOutput>> addReplicasForAllShards(
            final AddReplicasForAllShardsInput input); @Override ListenableFuture<RpcResult<RemoveAllShardReplicasOutput>> removeAllShardReplicas(
            final RemoveAllShardReplicasInput input); @Override ListenableFuture<RpcResult<ChangeMemberVotingStatesForShardOutput>> changeMemberVotingStatesForShard(
            final ChangeMemberVotingStatesForShardInput input); @Override ListenableFuture<RpcResult<ChangeMemberVotingStatesForAllShardsOutput>> changeMemberVotingStatesForAllShards(
            final ChangeMemberVotingStatesForAllShardsInput input); @Override ListenableFuture<RpcResult<FlipMemberVotingStatesForAllShardsOutput>> flipMemberVotingStatesForAllShards(
            final FlipMemberVotingStatesForAllShardsInput input); @Override ListenableFuture<RpcResult<GetShardRoleOutput>> getShardRole(final GetShardRoleInput input); @Override ListenableFuture<RpcResult<GetPrefixShardRoleOutput>> getPrefixShardRole(
            final GetPrefixShardRoleInput input); @Override ListenableFuture<RpcResult<BackupDatastoreOutput>> backupDatastore(final BackupDatastoreInput input); @Override ListenableFuture<RpcResult<GetKnownClientsForAllShardsOutput>> getKnownClientsForAllShards(
            final GetKnownClientsForAllShardsInput input);  }
@Test public void testGetPrefixShardRole() throws Exception { String name = "testGetPrefixShardRole"; String moduleShardsConfig = "module-shards-default-member-1.conf"; final MemberNode member1 = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name) .moduleShardsConfig(moduleShardsConfig).build(); member1.kit().waitUntilLeader(member1.configDataStore().getActorUtils(), "default"); }