Search in sources :

Example 21 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testFlipMemberVotingStatesWithVotingMembersDown.

@Test
public void testFlipMemberVotingStatesWithVotingMembersDown() throws Exception {
    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(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)));
    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();
    verifyVotingStates(leaderNode1.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE), new SimpleEntry<>("member-2", TRUE), new SimpleEntry<>("member-3", TRUE), new SimpleEntry<>("member-4", FALSE), new SimpleEntry<>("member-5", FALSE), new SimpleEntry<>("member-6", FALSE));
    final ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(), leaderNode1.operDataStore(), null, null);
    RpcResult<FlipMemberVotingStatesForAllShardsOutput> rpcResult = service1.flipMemberVotingStatesForAllShards(new FlipMemberVotingStatesForAllShardsInputBuilder().build()).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));
    // Members 2 and 3 are now non-voting but should get replicated with the new new server config.
    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", FALSE), new SimpleEntry<>("member-4", TRUE), new SimpleEntry<>("member-5", TRUE), new SimpleEntry<>("member-6", TRUE));
    // The leader (member 1) was changed to non-voting but it shouldn't be able to step down as leader yet
    // b/c it can't get a majority consensus with all voting members down. So verify it remains the leader.
    verifyRaftState(leaderNode1.configDataStore(), "cars", raftState -> {
        assertNotNull("Expected non-null leader Id", raftState.getLeader());
        assertTrue("Expected leader member-1", raftState.getLeader().contains("member-1"));
    });
}
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) FlipMemberVotingStatesForAllShardsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.FlipMemberVotingStatesForAllShardsInputBuilder) Test(org.junit.Test)

Example 22 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class PCEPTopologySessionListenerTest method testOnServerSessionManagerDown.

/**
 * All the pcep session registration should be closed when the session manager is closed.
 */
@Test
public void testOnServerSessionManagerDown() throws InterruptedException, ExecutionException {
    listener.onSessionUp(session);
    // the session should not be closed when session manager is up
    assertFalse(session.isClosed());
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = topologyRpcs.addLsp(createAddLspInput());
    stopSessionManager();
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
    // verify the session is closed after server session manager is closed
    assertTrue(session.isClosed());
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 23 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class PCEPTopologySessionListenerTest method testOnServerSessionManagerRestartAndSessionRecovery.

@Test
public void testOnServerSessionManagerRestartAndSessionRecovery() throws Exception {
    // close server session manager first
    stopSessionManager();
    assertFalse(session.isClosed());
    listener.onSessionUp(session);
    // verify the session was NOT added to topology
    checkNotPresentOperational(getDataBroker(), TOPO_IID);
    // verify the session is closed due to server session manager is closed
    assertTrue(session.isClosed());
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = topologyRpcs.addLsp(createAddLspInput());
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
    // PCC client is not there
    checkNotPresentOperational(getDataBroker(), pathComputationClientIId);
    // reset received message queue
    receivedMsgs.clear();
    // now we restart the session manager
    startSessionManager();
    // try to start the session again
    // notice since the session was terminated before, it is not usable anymore.
    // we need to get a new session instance. the new session will have the same local / remote preference
    session = getPCEPSession(getLocalPref(), getRemotePref());
    assertFalse(session.isClosed());
    listener.onSessionUp(session);
    assertFalse(session.isClosed());
    // create node
    topologyRpcs.addLsp(createAddLspInput());
    final Pcinitiate pcinitiate = (Pcinitiate) receivedMsgs.get(0);
    final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
    final Uint32 srpId = req.getSrp().getOperationId().getValue();
    final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, testAddress, testAddress, testAddress, Optional.empty());
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(TRUE).setRemove(FALSE).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
    listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), TOPO_IID, topology -> {
        assertEquals(1, topology.nonnullNode().size());
        return topology;
    });
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate) Test(org.junit.Test)

Example 24 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class PCEPTopologySessionListenerTest method testOnServerSessionManagerUnstarted.

/**
 * Verify the PCEP session should not be up when server session manager is down,
 * otherwise it would be a problem when the session is up while it's not registered with session manager.
 */
@Test
public void testOnServerSessionManagerUnstarted() throws InterruptedException, ExecutionException {
    stopSessionManager();
    assertFalse(session.isClosed());
    listener.onSessionUp(session);
    // verify the session was NOT added to topology
    checkNotPresentOperational(getDataBroker(), TOPO_IID);
    // verify the session is closed due to server session manager is closed
    assertTrue(session.isClosed());
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = topologyRpcs.addLsp(createAddLspInput());
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 25 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class ServerSessionManager method takeNodeState.

final synchronized TopologyNodeState takeNodeState(final InetAddress address, final TopologySessionListener sessionListener, final boolean retrieveNode) {
    final NodeId id = createNodeId(address);
    if (isClosed.get()) {
        LOG.error("Server Session Manager is closed. Unable to create topology node {} with listener {}", id, sessionListener);
        return null;
    }
    LOG.debug("Node {} requested by listener {}", id, sessionListener);
    TopologyNodeState ret = state.get(id);
    if (ret == null) {
        ret = new TopologyNodeState(dependencies.getDataBroker(), topology, id, DEFAULT_HOLD_STATE_NANOS);
        LOG.debug("Created topology node {} for id {} at {}", ret, id, ret.getNodeId());
        state.put(id, ret);
    }
    // if another listener requests the same session, close it
    final TopologySessionListener existingSessionListener = nodes.get(id);
    if (existingSessionListener != null && !sessionListener.equals(existingSessionListener)) {
        LOG.error("New session listener {} is in conflict with existing session listener {} on node {}," + " closing the existing one.", existingSessionListener, sessionListener, id);
        existingSessionListener.close();
    }
    ret.taken(retrieveNode);
    nodes.put(id, sessionListener);
    LOG.debug("Node {} bound to listener {}", id, sessionListener);
    return ret;
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)

Aggregations

Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)5 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)5 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)5 MatchEthernetSource (org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput)3 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput)3 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)2 AsId (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.AsId)2 GracefulRestart (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestart)2 Logging (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Logging)2 Multipath (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.multipathcontainer.Multipath)2 MultipathKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.multipathcontainer.MultipathKey)2 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors)2 NeighborsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.NeighborsKey)2 Networks (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks)2 NetworksKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey)2