Search in sources :

Example 91 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project controller by opendaylight.

the class GlobalBindingRTCServer method routedRpcBench.

@Override
public Future<RpcResult<RoutedRpcBenchOutput>> routedRpcBench(final RoutedRpcBenchInput input) {
    RoutedRpcBenchOutput output = new RoutedRpcBenchOutputBuilder(input).build();
    RpcResult<RoutedRpcBenchOutput> result = RpcResultBuilder.success(output).build();
    numRpcs++;
    return Futures.immediateFuture(result);
}
Also used : RoutedRpcBenchOutputBuilder(org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutputBuilder) RoutedRpcBenchOutput(org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutput)

Example 92 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project controller by opendaylight.

the class CarProvider method stopStressTest.

@Override
public Future<RpcResult<StopStressTestOutput>> stopStressTest() {
    stopThread();
    StopStressTestOutputBuilder stopStressTestOutput;
    stopStressTestOutput = new StopStressTestOutputBuilder().setSuccessCount(succcessCounter.longValue()).setFailureCount(failureCounter.longValue());
    final StopStressTestOutput result = stopStressTestOutput.build();
    LOG_PURCHASE_CAR.info("Executed Stop Stress test; No. of cars created {}; " + "No. of cars failed {}; ", succcessCounter, failureCounter);
    // clear counters
    succcessCounter.set(0);
    failureCounter.set(0);
    return Futures.immediateFuture(RpcResultBuilder.<StopStressTestOutput>success(result).build());
}
Also used : StopStressTestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StopStressTestOutput) StopStressTestOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StopStressTestOutputBuilder)

Example 93 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result 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 94 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method verifyShardResults.

private static void verifyShardResults(List<ShardResult> shardResults, ShardResult... expShardResults) {
    Map<String, ShardResult> expResultsMap = new HashMap<>();
    for (ShardResult r : expShardResults) {
        expResultsMap.put(r.getShardName() + "-" + r.getDataStoreType(), r);
    }
    for (ShardResult result : shardResults) {
        ShardResult exp = expResultsMap.remove(result.getShardName() + "-" + result.getDataStoreType());
        assertNotNull(String.format("Unexpected result for shard %s, type %s", result.getShardName(), result.getDataStoreType()), exp);
        assertEquals("isSucceeded", exp.isSucceeded(), result.isSucceeded());
        if (exp.isSucceeded()) {
            assertNull("Expected null error message", result.getErrorMessage());
        } else {
            assertNotNull("Expected error message", result.getErrorMessage());
        }
    }
    if (!expResultsMap.isEmpty()) {
        fail("Missing shard results for " + expResultsMap.keySet());
    }
}
Also used : HashMap(java.util.HashMap) ShardResult(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.shard.result.output.ShardResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 95 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testFlipMemberVotingStates.

@Test
public void testFlipMemberVotingStates() throws Exception {
    String name = "testFlipMemberVotingStates";
    ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(new ServerInfo("member-1", true), new ServerInfo("member-2", true), new ServerInfo("member-3", false)));
    setupPersistedServerConfigPayload(persistedServerConfig, "member-1", name, "cars", "people");
    setupPersistedServerConfigPayload(persistedServerConfig, "member-2", name, "cars", "people");
    setupPersistedServerConfigPayload(persistedServerConfig, "member-3", name, "cars", "people");
    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();
    leaderNode1.operDataStore().waitTillReady();
    replicaNode3.configDataStore().waitTillReady();
    replicaNode3.operDataStore().waitTillReady();
    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);
    RpcResult<FlipMemberVotingStatesForAllShardsOutput> rpcResult = service3.flipMemberVotingStatesForAllShards().get(10, TimeUnit.SECONDS);
    FlipMemberVotingStatesForAllShardsOutput result = verifySuccessfulRpcResult(rpcResult);
    verifyShardResults(result.getShardResult(), successShardResult("cars", DataStoreType.Config), successShardResult("people", DataStoreType.Config), successShardResult("cars", DataStoreType.Operational), successShardResult("people", DataStoreType.Operational));
    verifyVotingStates(new AbstractDataStore[] { leaderNode1.configDataStore(), leaderNode1.operDataStore(), replicaNode2.configDataStore(), replicaNode2.operDataStore(), replicaNode3.configDataStore(), replicaNode3.operDataStore() }, new String[] { "cars", "people" }, new SimpleEntry<>("member-1", FALSE), new SimpleEntry<>("member-2", FALSE), new SimpleEntry<>("member-3", TRUE));
    // Leadership should have transferred to member 3 since it is the only remaining voting member.
    verifyRaftState(leaderNode1.configDataStore(), "cars", raftState -> {
        assertNotNull("Expected non-null leader Id", raftState.getLeader());
        assertTrue("Expected leader member-1. Actual: " + raftState.getLeader(), raftState.getLeader().contains("member-3"));
    });
    verifyRaftState(leaderNode1.operDataStore(), "cars", raftState -> {
        assertNotNull("Expected non-null leader Id", raftState.getLeader());
        assertTrue("Expected leader member-1. Actual: " + raftState.getLeader(), raftState.getLeader().contains("member-3"));
    });
    // Flip the voting states back to the original states.
    rpcResult = service3.flipMemberVotingStatesForAllShards().get(10, TimeUnit.SECONDS);
    result = verifySuccessfulRpcResult(rpcResult);
    verifyShardResults(result.getShardResult(), successShardResult("cars", DataStoreType.Config), successShardResult("people", DataStoreType.Config), successShardResult("cars", DataStoreType.Operational), successShardResult("people", DataStoreType.Operational));
    verifyVotingStates(new AbstractDataStore[] { leaderNode1.configDataStore(), leaderNode1.operDataStore(), replicaNode2.configDataStore(), replicaNode2.operDataStore(), replicaNode3.configDataStore(), replicaNode3.operDataStore() }, new String[] { "cars", "people" }, new SimpleEntry<>("member-1", TRUE), new SimpleEntry<>("member-2", TRUE), new SimpleEntry<>("member-3", FALSE));
    // Leadership should have transferred to member 1 or 2.
    verifyRaftState(leaderNode1.configDataStore(), "cars", raftState -> {
        assertNotNull("Expected non-null leader Id", raftState.getLeader());
        assertTrue("Expected leader member-1 or member-2. Actual: " + raftState.getLeader(), raftState.getLeader().contains("member-1") || raftState.getLeader().contains("member-2"));
    });
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) ServerConfigurationPayload(org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload) ServerInfo(org.opendaylight.controller.cluster.raft.persisted.ServerInfo) FlipMemberVotingStatesForAllShardsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.FlipMemberVotingStatesForAllShardsOutput) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)348 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)174 ByteBuf (io.netty.buffer.ByteBuf)97 ArrayList (java.util.ArrayList)94 ExecutionException (java.util.concurrent.ExecutionException)92 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)46 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)40 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)33 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)33 List (java.util.List)31 BigInteger (java.math.BigInteger)29 Collections (java.util.Collections)26 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)24 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)24 Nonnull (javax.annotation.Nonnull)23 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)22 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)22 RpcError (org.opendaylight.yangtools.yang.common.RpcError)22