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);
}
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);
}
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;
});
}
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();
}
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);
}
Aggregations