use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class BmpMonitorConfigFileProcessor method loadConfiguration.
@Override
public synchronized void loadConfiguration(final NormalizedNode<?, ?> dto) {
final ContainerNode bmpMonitorsConfigsContainer = (ContainerNode) dto;
final MapNode monitorsList = (MapNode) bmpMonitorsConfigsContainer.getChild(this.bmpMonitorsYii.getLastPathArgument()).orElse(null);
if (monitorsList == null) {
return;
}
final Collection<MapEntryNode> bmpMonitorConfig = monitorsList.getValue();
final WriteTransaction wtx = this.dataBroker.newWriteOnlyTransaction();
bmpMonitorConfig.stream().map(topology -> this.bindingSerializer.fromNormalizedNode(this.bmpMonitorsYii, topology)).filter(Objects::nonNull).forEach(bi -> processBmpMonitorConfig((BmpMonitorConfig) bi.getValue(), wtx));
try {
wtx.submit().get();
} catch (final ExecutionException | InterruptedException e) {
LOG.warn("Failed to create Bmp config", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project controller by opendaylight.
the class EventSourceTopic method notifyExistingNodes.
private void notifyExistingNodes(final EventSourceTopology eventSourceTopology) {
LOG.debug("Notify existing nodes");
final Pattern nodeRegex = this.nodeIdPattern;
final ReadOnlyTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction();
final ListenableFuture<Optional<Topology>> future = tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
Futures.addCallback(future, new FutureCallback<Optional<Topology>>() {
@Override
public void onSuccess(@Nonnull final Optional<Topology> data) {
if (data.isPresent()) {
final List<Node> nodes = data.get().getNode();
if (nodes != null) {
for (final Node node : nodes) {
if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) {
notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, node.getKey()));
}
}
}
}
tx.close();
}
@Override
public void onFailure(final Throwable ex) {
LOG.error("Can not notify existing nodes", ex);
tx.close();
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class StateSynchronizationAvoidanceProcedureTest method testNodePersisted.
@Test
public void testNodePersisted() throws ReadFailedException {
final PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
this.listener.onSessionUp(session);
// report LSP + LSP-DB version number
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build()).build()).build()).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(1L)), null);
this.listener.onMessage(session, pcRpt);
// check topology
readDataOperational(getDataBroker(), this.pathComputationClientIId.builder().augmentation(PathComputationClient1.class).child(LspDbVersion.class).build(), dbVersion -> {
assertEquals(1L, dbVersion.getLspDbVersionValue().longValue());
return dbVersion;
});
// drop session
this.listener.onSessionDown(session, new IllegalStateException());
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertFalse(topology.getNode().isEmpty());
return topology;
});
// check topology - node is persisted
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnSessionTermination.
@Test
public void testOnSessionTermination() throws Exception {
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;
});
assertFalse(this.session.isClosed());
// node should be removed after termination
this.listener.onSessionTerminated(this.session, new PCEPCloseTermination(TerminationReason.UNKNOWN));
assertTrue(this.session.isClosed());
checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest 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, TransactionCommitFailedException, ReadFailedException {
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());
}
Aggregations