use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project controller by opendaylight.
the class ProduceTransactionsHandler method start.
public static ListenableFuture<RpcResult<ProduceTransactionsOutput>> start(final DOMDataTreeService domDataTreeService, final ProduceTransactionsInput input) {
final String id = input.getId();
LOG.debug("Filling the item list {} with initial values.", id);
final YangInstanceIdentifier idListWithKey = ID_INT_YID.node(new NodeIdentifierWithPredicates(ID_INT, ID, id));
final DOMDataTreeProducer itemProducer = domDataTreeService.createProducer(Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey)));
final DOMDataTreeCursorAwareTransaction tx = itemProducer.createTransaction(false);
final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey));
final MapNode list = ImmutableNodes.mapNodeBuilder(ITEM).build();
cursor.write(list.getIdentifier(), list);
cursor.close();
try {
tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Unable to fill the initial item list.", e);
closeProducer(itemProducer);
return Futures.immediateFuture(RpcResultBuilder.<ProduceTransactionsOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build());
}
final ProduceTransactionsHandler handler = new ProduceTransactionsHandler(itemProducer, new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey.node(list.getIdentifier()).toOptimized()), input);
// It is handler's responsibility to close itemProducer when the work is finished.
handler.doStart();
return handler.future;
}
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 close.
@Override
public synchronized void close() throws Exception {
LOG.info("Closing TopologyStatsProvider service.", this);
this.scheduleTask.cancel(true);
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
for (final KeyedInstanceIdentifier<Node, NodeKey> statId : this.statsMap.keySet()) {
wTx.delete(LogicalDatastoreType.OPERATIONAL, statId);
}
wTx.submit().get();
this.statsMap.clear();
this.transactionChain.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 Stateful07TopologySessionListenerTest method testOnServerSessionManagerRestartAndSessionRecovery.
@Test
public void testOnServerSessionManagerRestartAndSessionRecovery() throws Exception {
// close server session manager first
stopSessionManager();
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.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(this.session.isClosed());
// send request
final Future<RpcResult<AddLspOutput>> futureOutput = this.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(), this.pathComputationClientIId);
// reset received message queue
this.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
this.session = getPCEPSession(getLocalPref(), getRemotePref());
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
assertFalse(this.session.isClosed());
// create node
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
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()));
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertEquals(1, topology.getNode().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 Stateful07TopologySessionListenerTest method testDuplicatedSession.
/**
* When a session is somehow duplicated in controller, the controller should drop existing session.
*/
@Test
public void testDuplicatedSession() throws ReadFailedException {
this.listener.onSessionUp(this.session);
// create node
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
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()));
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertEquals(1, topology.getNode().size());
return topology;
});
// now we do session up again
this.listener.onSessionUp(this.session);
assertTrue(this.session.isClosed());
// node should be removed after termination
checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
assertFalse(this.receivedMsgs.isEmpty());
// the last message should be a Close message
assertTrue(this.receivedMsgs.get(this.receivedMsgs.size() - 1) instanceof Close);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class OpenflowpluginTestServiceProvider method register.
public ObjectRegistration<OpenflowpluginTestServiceProvider> register(final ProviderContext ctx) {
RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx.<SalFlowService>addRoutedRpcImplementation(SalFlowService.class, this);
setFlowRegistration(addRoutedRpcImplementation);
InstanceIdentifierBuilder<Nodes> builderII = InstanceIdentifier.<Nodes>builder(Nodes.class);
NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifierBuilder<Node> nodeIdentifier = builderII.<Node, NodeKey>child(Node.class, nodeKey);
InstanceIdentifier<Node> instance = nodeIdentifier.build();
flowRegistration.registerPath(NodeContext.class, instance);
RoutedRpcRegistration<SalFlowService> flowRegistration2 = getFlowRegistration();
return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {
@Override
protected void removeRegistration() {
flowRegistration2.close();
}
};
}
Aggregations