Search in sources :

Example 46 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project bgpcep by opendaylight.

the class TopologyProgrammingTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    doNothing().when(listener).close();
    doReturn(true).when(instruction).checkedExecutionStart();
    doNothing().when(instruction).executionCompleted(InstructionStatus.Failed, null);
    doNothing().when(instruction).executionCompleted(any(InstructionStatus.class), any(Details.class));
    doReturn(Futures.immediateFuture(instruction)).when(scheduler).scheduleInstruction(any(SubmitInstructionInput.class));
    topologyProgramming = new TopologyProgramming(scheduler, manager);
    final PCEPSession session = getPCEPSession(getLocalPref(), getRemotePref());
    listener.onSessionUp(session);
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) InstructionStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionStatus) Details(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.Details) SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Before(org.junit.Before)

Example 47 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project bgpcep by opendaylight.

the class PCEPTopologySessionListenerTest method testDuplicatedSession.

/**
 * When a session is somehow duplicated in controller, the controller should drop existing session.
 */
@Test
public void testDuplicatedSession() throws ExecutionException, InterruptedException {
    listener.onSessionUp(session);
    // 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;
    });
    // now we do session up again
    listener.onSessionUp(session);
    assertTrue(session.isClosed());
    // node should be removed after termination
    checkNotPresentOperational(getDataBroker(), pathComputationClientIId);
    assertFalse(receivedMsgs.isEmpty());
    // the last message should be a Close message
    assertTrue(receivedMsgs.get(receivedMsgs.size() - 1) instanceof Close);
}
Also used : 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) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Close(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close) 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 48 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close 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 49 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project bgpcep by opendaylight.

the class TopologyStatsProviderImpl method shutdown.

private synchronized void shutdown() throws InterruptedException, ExecutionException {
    // Try to get a transaction chain and indicate we are done
    final TransactionChain chain = accessChain();
    transactionChain = null;
    dataBroker = null;
    if (chain == null) {
        // Belt & suspenders so we do not error out elsewhere
        LOG.warn("Cannot acquire transaction chain, skipping cleanup");
        return;
    }
    // Issue deletes for all registered stats
    final WriteTransaction wTx = chain.newWriteOnlyTransaction();
    for (final KeyedInstanceIdentifier<Node, NodeKey> statId : statsMap.keySet()) {
        wTx.delete(LogicalDatastoreType.OPERATIONAL, statId);
    }
    statsMap.clear();
    // Fire the transaction commit ...
    final FluentFuture<?> future = wTx.commit();
    // ... close the transaction chain ...
    chain.close();
    // ... and wait for transaction commit to complete
    LOG.debug("Awaiting finish of TopologyStatsProvider cleanup");
    future.get();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 50 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project bgpcep by opendaylight.

the class PCEPCloseMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf out) {
    checkArgument(message instanceof CloseMessage, "Wrong instance of Message. Passed instance of %s. Need CloseMessage.", message.getClass());
    final CCloseMessage close = ((CloseMessage) message).getCCloseMessage();
    checkArgument(close.getCClose() != null, "Close Object must be present in Close Message.");
    final ByteBuf buffer = Unpooled.buffer();
    serializeObject(close.getCClose(), buffer);
    MessageUtil.formatMessage(TYPE, buffer, out);
}
Also used : CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.CloseMessage) CCloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessage) CCloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessage) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

Test (org.junit.Test)25 InetSocketAddress (java.net.InetSocketAddress)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)9 Before (org.junit.Before)8 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)6 Optional (com.google.common.base.Optional)5 ChannelFuture (io.netty.channel.ChannelFuture)5 ChannelHandler (io.netty.channel.ChannelHandler)5 TimeUnit (java.util.concurrent.TimeUnit)5 Channel (io.netty.channel.Channel)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 Notification (org.opendaylight.yangtools.yang.binding.Notification)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4