Search in sources :

Example 41 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testRemoveShardReplica.

@Test
public void testRemoveShardReplica() throws Exception {
    String name = "testRemoveShardReplica";
    String moduleShardsConfig = "module-shards-member1-and-2-and-3.conf";
    final MemberNode leaderNode1 = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig(moduleShardsConfig).datastoreContextBuilder(DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(1)).build();
    final MemberNode replicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
    final MemberNode replicaNode3 = MemberNode.builder(memberNodes).akkaConfig("Member3").testName(name).moduleShardsConfig(moduleShardsConfig).build();
    leaderNode1.configDataStore().waitTillReady();
    replicaNode3.configDataStore().waitTillReady();
    verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars", "member-2", "member-3");
    verifyRaftPeersPresent(replicaNode2.configDataStore(), "cars", "member-1", "member-3");
    verifyRaftPeersPresent(replicaNode3.configDataStore(), "cars", "member-1", "member-2");
    // Invoke RPC service on member-3 to remove it's local shard
    ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(), replicaNode3.operDataStore(), null);
    RpcResult<Void> rpcResult = service3.removeShardReplica(new RemoveShardReplicaInputBuilder().setShardName("cars").setMemberName("member-3").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars", "member-2");
    verifyRaftPeersPresent(replicaNode2.configDataStore(), "cars", "member-1");
    verifyNoShardPresent(replicaNode3.configDataStore(), "cars");
    // Restart member-2 and verify member-3 isn't present.
    Cluster.get(leaderNode1.kit().getSystem()).down(Cluster.get(replicaNode2.kit().getSystem()).selfAddress());
    replicaNode2.cleanup();
    MemberNode newPeplicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
    newPeplicaNode2.configDataStore().waitTillReady();
    verifyRaftPeersPresent(newPeplicaNode2.configDataStore(), "cars", "member-1");
    // Invoke RPC service on member-1 to remove member-2
    ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(), leaderNode1.operDataStore(), null);
    rpcResult = service1.removeShardReplica(new RemoveShardReplicaInputBuilder().setShardName("cars").setMemberName("member-2").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars");
    verifyNoShardPresent(newPeplicaNode2.configDataStore(), "cars");
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) RemoveShardReplicaInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveShardReplicaInputBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 42 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testAddReplicasForAllShards.

@Test
public void testAddReplicasForAllShards() throws Exception {
    String name = "testAddReplicasForAllShards";
    String moduleShardsConfig = "module-shards-member1.conf";
    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));
    leaderNode1.configDataStore().getActorContext().getShardManager().tell(new CreateShard(petsModuleConfig, Shard.builder(), null), leaderNode1.kit().getRef());
    leaderNode1.kit().expectMsgClass(Success.class);
    leaderNode1.kit().waitUntilLeader(leaderNode1.configDataStore().getActorContext(), "pets");
    MemberNode newReplicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
    leaderNode1.waitForMembersUp("member-2");
    newReplicaNode2.waitForMembersUp("member-1");
    newReplicaNode2.configDataStore().getActorContext().getShardManager().tell(new CreateShard(petsModuleConfig, Shard.builder(), null), newReplicaNode2.kit().getRef());
    newReplicaNode2.kit().expectMsgClass(Success.class);
    newReplicaNode2.operDataStore().getActorContext().getShardManager().tell(new CreateShard(new ModuleShardConfiguration(URI.create("no-leader-ns"), "no-leader-module", "no-leader", null, Collections.singletonList(MEMBER_1)), Shard.builder(), null), newReplicaNode2.kit().getRef());
    newReplicaNode2.kit().expectMsgClass(Success.class);
    ClusterAdminRpcService service = new ClusterAdminRpcService(newReplicaNode2.configDataStore(), newReplicaNode2.operDataStore(), null);
    RpcResult<AddReplicasForAllShardsOutput> rpcResult = service.addReplicasForAllShards().get(10, TimeUnit.SECONDS);
    AddReplicasForAllShardsOutput result = verifySuccessfulRpcResult(rpcResult);
    verifyShardResults(result.getShardResult(), successShardResult("cars", DataStoreType.Config), successShardResult("people", DataStoreType.Config), successShardResult("pets", DataStoreType.Config), successShardResult("cars", DataStoreType.Operational), successShardResult("people", DataStoreType.Operational), failedShardResult("no-leader", DataStoreType.Operational));
    verifyRaftPeersPresent(newReplicaNode2.configDataStore(), "cars", "member-1");
    verifyRaftPeersPresent(newReplicaNode2.configDataStore(), "people", "member-1");
    verifyRaftPeersPresent(newReplicaNode2.configDataStore(), "pets", "member-1");
    verifyRaftPeersPresent(newReplicaNode2.operDataStore(), "cars", "member-1");
    verifyRaftPeersPresent(newReplicaNode2.operDataStore(), "people", "member-1");
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AddReplicasForAllShardsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddReplicasForAllShardsOutput) CreateShard(org.opendaylight.controller.cluster.datastore.messages.CreateShard) ModuleShardConfiguration(org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration) Test(org.junit.Test)

Example 43 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testChangeMemberVotingStatesForSingleNodeShard.

@Test
public void testChangeMemberVotingStatesForSingleNodeShard() throws Exception {
    String name = "testChangeMemberVotingStatesForSingleNodeShard";
    String moduleShardsConfig = "module-shards-member1.conf";
    MemberNode leaderNode = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig(moduleShardsConfig).datastoreContextBuilder(DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(1)).build();
    leaderNode.configDataStore().waitTillReady();
    // Invoke RPC service on member-3 to change voting status
    ClusterAdminRpcService service = new ClusterAdminRpcService(leaderNode.configDataStore(), leaderNode.operDataStore(), null);
    RpcResult<Void> rpcResult = service.changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder().setShardName("cars").setDataStoreType(DataStoreType.Config).setMemberVotingState(ImmutableList.of(new MemberVotingStateBuilder().setMemberName("member-1").setVoting(FALSE).build())).build()).get(10, TimeUnit.SECONDS);
    verifyFailedRpcResult(rpcResult);
    verifyVotingStates(leaderNode.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE));
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) MemberVotingStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingStateBuilder) ChangeMemberVotingStatesForShardInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForShardInputBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 44 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service 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 45 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testAddShardReplicaFailures.

@Test
public void testAddShardReplicaFailures() throws Exception {
    String name = "testAddShardReplicaFailures";
    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);
    RpcResult<Void> rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
    verifyFailedRpcResult(rpcResult);
    rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setShardName("cars").build()).get(10, TimeUnit.SECONDS);
    verifyFailedRpcResult(rpcResult);
    rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setShardName("people").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
    verifyFailedRpcResult(rpcResult);
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) AddShardReplicaInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddShardReplicaInputBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)36 BigInteger (java.math.BigInteger)33 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)21 ExecutionException (java.util.concurrent.ExecutionException)19 CoreException (org.eclipse.core.runtime.CoreException)18 List (java.util.List)15 Test (org.junit.Test)15 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)15 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 BoundServices (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)12 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)10 ServerPort (org.eclipse.wst.server.core.ServerPort)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)9