import akka.actor.PoisonPill;
import akka.actor.Status.Success;
import akka.cluster.Cluster;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import java.io.File;
import java.io.FileInputStream;
-import java.net.URI;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.shard.result.output.ShardResultKey;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
String fileName = "target/testBackupDatastore";
new File(fileName).delete();
- ClusterAdminRpcService service = new ClusterAdminRpcService(node.configDataStore(), node.operDataStore(), null);
+ final ClusterAdminRpcService service = new ClusterAdminRpcService(node.configDataStore(), node.operDataStore(),
+ null, null);
RpcResult<BackupDatastoreOutput> rpcResult = service .backupDatastore(new BackupDatastoreInputBuilder()
.setFilePath(fileName).build()).get(5, TimeUnit.SECONDS);
shardNames.add(s.getName());
}
- assertEquals("DatastoreSnapshot shard names", Sets.newHashSet(expShardNames), shardNames);
+ assertEquals("DatastoreSnapshot shard names", Set.of(expShardNames), shardNames);
}
@Test
verifyRaftPeersPresent(newReplicaNode2.operDataStore(), "cars", "member-1", "member-3");
// Write data to member-2's config datastore and read/verify via member-3
- final NormalizedNode<?, ?> configCarsNode = writeCarsNodeAndVerify(newReplicaNode2.configDataStore(),
+ final NormalizedNode configCarsNode = writeCarsNodeAndVerify(newReplicaNode2.configDataStore(),
newReplicaNode3.configDataStore());
// Write data to member-3's oper datastore and read/verify via member-2
MemberNode memberNode = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name)
.moduleShardsConfig("module-shards-cars-member-1.conf").build();
- ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(),
- memberNode.operDataStore(), null);
+ final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(),
+ memberNode.operDataStore(), null, null);
RpcResult<AddShardReplicaOutput> rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder()
.setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
}
- private static NormalizedNode<?, ?> writeCarsNodeAndVerify(final AbstractDataStore writeToStore,
+ private static NormalizedNode writeCarsNodeAndVerify(final AbstractDataStore writeToStore,
final AbstractDataStore readFromStore) throws Exception {
DOMStoreWriteTransaction writeTx = writeToStore.newWriteOnlyTransaction();
- NormalizedNode<?, ?> carsNode = CarsModel.create();
+ NormalizedNode carsNode = CarsModel.create();
writeTx.write(CarsModel.BASE_PATH, carsNode);
DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
}
private static void readCarsNodeAndVerify(final AbstractDataStore readFromStore,
- final NormalizedNode<?, ?> expCarsNode) throws Exception {
- Optional<NormalizedNode<?, ?>> optional = readFromStore.newReadOnlyTransaction().read(CarsModel.BASE_PATH)
+ final NormalizedNode expCarsNode) throws Exception {
+ Optional<NormalizedNode> optional = readFromStore.newReadOnlyTransaction().read(CarsModel.BASE_PATH)
.get(15, TimeUnit.SECONDS);
assertTrue("isPresent", optional.isPresent());
assertEquals("Data node", expCarsNode, optional.get());
final String... peerMemberNames) throws Exception {
memberNode.waitForMembersUp(peerMemberNames);
- ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(),
- memberNode.operDataStore(), null);
+ final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(),
+ memberNode.operDataStore(), null, null);
RpcResult<AddShardReplicaOutput> rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder()
.setShardName(shardName).setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
private static void doMakeShardLeaderLocal(final MemberNode memberNode, final String shardName,
final String newLeader) throws Exception {
- ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(),
- memberNode.operDataStore(), null);
+ final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(),
+ memberNode.operDataStore(), null, null);
final RpcResult<MakeLeaderLocalOutput> rpcResult = service.makeLeaderLocal(new MakeLeaderLocalInputBuilder()
.setDataStoreType(DataStoreType.Config).setShardName(shardName).build())
// Invoke RPC service on member-3 to remove it's local shard
- ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
- replicaNode3.operDataStore(), null);
+ final ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
+ replicaNode3.operDataStore(), null, null);
RpcResult<RemoveShardReplicaOutput> rpcResult = service3.removeShardReplica(new RemoveShardReplicaInputBuilder()
.setShardName("cars").setMemberName("member-3").setDataStoreType(DataStoreType.Config).build())
// Invoke RPC service on member-1 to remove member-2
- ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(),
- leaderNode1.operDataStore(), null);
+ final ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(),
+ leaderNode1.operDataStore(), null, null);
rpcResult = service1.removeShardReplica(new RemoveShardReplicaInputBuilder().setShardName("cars")
.setMemberName("member-2").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
// Invoke RPC service on leader member-1 to remove it's local shard
- ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(),
- leaderNode1.operDataStore(), null);
+ final ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(),
+ leaderNode1.operDataStore(), null, null);
RpcResult<RemoveShardReplicaOutput> rpcResult = service1.removeShardReplica(new RemoveShardReplicaInputBuilder()
.setShardName("cars").setMemberName("member-1").setDataStoreType(DataStoreType.Config).build())
MemberNode leaderNode1 = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name)
.moduleShardsConfig(moduleShardsConfig).waitForShardLeader("cars", "people").build();
- ModuleShardConfiguration petsModuleConfig = new ModuleShardConfiguration(URI.create("pets-ns"), "pets-module",
- "pets", null,
- Collections.singletonList(MEMBER_1));
+ ModuleShardConfiguration petsModuleConfig = new ModuleShardConfiguration(
+ XMLNamespace.of("pets-ns"), "pets-module", "pets", null, List.of(MEMBER_1));
leaderNode1.configDataStore().getActorUtils().getShardManager().tell(
new CreateShard(petsModuleConfig, Shard.builder(), null), leaderNode1.kit().getRef());
leaderNode1.kit().expectMsgClass(Success.class);
newReplicaNode2.kit().expectMsgClass(Success.class);
newReplicaNode2.operDataStore().getActorUtils().getShardManager().tell(
- new CreateShard(new ModuleShardConfiguration(URI.create("no-leader-ns"), "no-leader-module",
- "no-leader", null,
- Collections.singletonList(MEMBER_1)),
+ new CreateShard(new ModuleShardConfiguration(XMLNamespace.of("no-leader-ns"), "no-leader-module",
+ "no-leader", null, List.of(MEMBER_1)),
Shard.builder(), null),
newReplicaNode2.kit().getRef());
newReplicaNode2.kit().expectMsgClass(Success.class);
- ClusterAdminRpcService service = new ClusterAdminRpcService(newReplicaNode2.configDataStore(),
- newReplicaNode2.operDataStore(), null);
+ final ClusterAdminRpcService service = new ClusterAdminRpcService(newReplicaNode2.configDataStore(),
+ newReplicaNode2.operDataStore(), null, null);
RpcResult<AddReplicasForAllShardsOutput> rpcResult = service.addReplicasForAllShards(
new AddReplicasForAllShardsInputBuilder().build()).get(10, TimeUnit.SECONDS);
verifyRaftPeersPresent(replicaNode2.configDataStore(), "cars", "member-1", "member-3");
verifyRaftPeersPresent(replicaNode3.configDataStore(), "cars", "member-1", "member-2");
- ModuleShardConfiguration petsModuleConfig = new ModuleShardConfiguration(URI.create("pets-ns"), "pets-module",
- "pets", null, Arrays.asList(MEMBER_1, MEMBER_2, MEMBER_3));
+ ModuleShardConfiguration petsModuleConfig = new ModuleShardConfiguration(XMLNamespace.of("pets-ns"),
+ "pets-module", "pets", null, List.of(MEMBER_1, MEMBER_2, MEMBER_3));
leaderNode1.configDataStore().getActorUtils().getShardManager().tell(
new CreateShard(petsModuleConfig, Shard.builder(), null), leaderNode1.kit().getRef());
leaderNode1.kit().expectMsgClass(Success.class);
verifyRaftPeersPresent(replicaNode2.configDataStore(), "pets", "member-1", "member-3");
verifyRaftPeersPresent(replicaNode3.configDataStore(), "pets", "member-1", "member-2");
- ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
- replicaNode3.operDataStore(), null);
+ final ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
+ replicaNode3.operDataStore(), null, null);
RpcResult<RemoveAllShardReplicasOutput> rpcResult = service3.removeAllShardReplicas(
new RemoveAllShardReplicasInputBuilder().setMemberName("member-3").build()).get(10, TimeUnit.SECONDS);
// Invoke RPC service on member-3 to change voting status
- ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
- replicaNode3.operDataStore(), null);
+ final ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
+ replicaNode3.operDataStore(), null, null);
RpcResult<ChangeMemberVotingStatesForShardOutput> rpcResult = service3
.changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder()
.setShardName("cars").setDataStoreType(DataStoreType.Config)
- .setMemberVotingState(ImmutableList.of(
+ .setMemberVotingState(List.of(
new MemberVotingStateBuilder().setMemberName("member-2").setVoting(FALSE).build(),
new MemberVotingStateBuilder().setMemberName("member-3").setVoting(FALSE).build()))
.build())
// Invoke RPC service on member-3 to change voting status
- ClusterAdminRpcService service = new ClusterAdminRpcService(leaderNode.configDataStore(),
- leaderNode.operDataStore(), null);
+ final ClusterAdminRpcService service = new ClusterAdminRpcService(leaderNode.configDataStore(),
+ leaderNode.operDataStore(), null, null);
RpcResult<ChangeMemberVotingStatesForShardOutput> rpcResult = service
.changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder()
.setShardName("cars").setDataStoreType(DataStoreType.Config)
- .setMemberVotingState(ImmutableList
- .of(new MemberVotingStateBuilder().setMemberName("member-1").setVoting(FALSE).build()))
+ .setMemberVotingState(List.of(new MemberVotingStateBuilder()
+ .setMemberName("member-1")
+ .setVoting(FALSE)
+ .build()))
.build())
.get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
// Invoke RPC service on member-3 to change voting status
- ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
- replicaNode3.operDataStore(), null);
+ final ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
+ replicaNode3.operDataStore(), null, null);
RpcResult<ChangeMemberVotingStatesForAllShardsOutput> rpcResult = service3.changeMemberVotingStatesForAllShards(
- new ChangeMemberVotingStatesForAllShardsInputBuilder().setMemberVotingState(ImmutableList.of(
+ new ChangeMemberVotingStatesForAllShardsInputBuilder().setMemberVotingState(List.of(
new MemberVotingStateBuilder().setMemberName("member-2").setVoting(FALSE).build(),
new MemberVotingStateBuilder().setMemberName("member-3").setVoting(FALSE).build())).build())
.get(10, TimeUnit.SECONDS);
public void testFlipMemberVotingStates() throws Exception {
String name = "testFlipMemberVotingStates";
- ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
+ ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(List.of(
new ServerInfo("member-1", true), new ServerInfo("member-2", true),
new ServerInfo("member-3", false)));
verifyVotingStates(leaderNode1.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE),
new SimpleEntry<>("member-2", TRUE), new SimpleEntry<>("member-3", FALSE));
- ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
- replicaNode3.operDataStore(), null);
+ final ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(),
+ replicaNode3.operDataStore(), null, null);
RpcResult<FlipMemberVotingStatesForAllShardsOutput> rpcResult = service3.flipMemberVotingStatesForAllShards(
new FlipMemberVotingStatesForAllShardsInputBuilder().build()).get(10, TimeUnit.SECONDS);
// Members 1, 2, and 3 are initially started up as non-voting. Members 4, 5, and 6 are initially
// non-voting and simulated as down by not starting them up.
- ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
+ ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(List.of(
new ServerInfo("member-1", false), new ServerInfo("member-2", false),
new ServerInfo("member-3", false), new ServerInfo("member-4", true),
new ServerInfo("member-5", true), new ServerInfo("member-6", true)));
verifyRaftState(replicaNode1.configDataStore(), "cars", raftState ->
assertEquals("Expected raft state", RaftState.Follower.toString(), raftState.getRaftState()));
- ClusterAdminRpcService service1 = new ClusterAdminRpcService(replicaNode1.configDataStore(),
- replicaNode1.operDataStore(), null);
+ final ClusterAdminRpcService service1 = new ClusterAdminRpcService(replicaNode1.configDataStore(),
+ replicaNode1.operDataStore(), null, null);
RpcResult<FlipMemberVotingStatesForAllShardsOutput> rpcResult = service1.flipMemberVotingStatesForAllShards(
new FlipMemberVotingStatesForAllShardsInputBuilder().build()).get(10, TimeUnit.SECONDS);
String name = "testFlipMemberVotingStatesWithVotingMembersDown";
// Members 4, 5, and 6 are initially non-voting and simulated as down by not starting them up.
- ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
+ ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(List.of(
new ServerInfo("member-1", true), new ServerInfo("member-2", true),
new ServerInfo("member-3", true), new ServerInfo("member-4", false),
new ServerInfo("member-5", false), new ServerInfo("member-6", false)));
new SimpleEntry<>("member-4", FALSE), new SimpleEntry<>("member-5", FALSE),
new SimpleEntry<>("member-6", FALSE));
- ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(),
- leaderNode1.operDataStore(), null);
+ final ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(),
+ leaderNode1.operDataStore(), null, null);
RpcResult<FlipMemberVotingStatesForAllShardsOutput> rpcResult = service1.flipMemberVotingStatesForAllShards(
new FlipMemberVotingStatesForAllShardsInputBuilder().build()).get(10, TimeUnit.SECONDS);
type + datastoreTypeSuffix).toString(), info.isVoting()));
}
- String shardID = ShardIdentifier.create(shard, MemberName.forName(member),
+ final String shardID = ShardIdentifier.create(shard, MemberName.forName(member),
type + datastoreTypeSuffix).toString();
InMemoryJournal.addEntry(shardID, 1, new UpdateElectionTerm(1, null));
InMemoryJournal.addEntry(shardID, 2, new SimpleReplicatedLogEntry(0, 1,