use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class BmpRibInWriter method removeRoutes.
private synchronized void removeRoutes(final MpUnreachNlri nlri) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
LOG.trace("Removing routes {}", nlri);
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
ctx.removeRoutes(tx, nlri);
tx.submit();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class BmpRouterImpl method onInitiate.
private synchronized void onInitiate(final InitiationMessage initiation) {
Preconditions.checkState(isDatastoreWritable());
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.merge(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)).withChild(ImmutableNodes.leafNode(ROUTER_NAME_QNAME, initiation.getTlvs().getNameTlv().getName())).withChild(ImmutableNodes.leafNode(ROUTER_DESCRIPTION_QNAME, initiation.getTlvs().getDescriptionTlv().getDescription())).withChild(ImmutableNodes.leafNode(ROUTER_INFO_QNAME, getStringInfo(initiation.getTlvs().getStringInformation()))).withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, UP)).build());
wTx.submit();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class BmpRouterImpl method tearDown.
@GuardedBy("this")
@SuppressWarnings("checkstyle:IllegalCatch")
private synchronized void tearDown() {
// the session has been teared down before
if (this.session == null) {
return;
}
// we want to display remote router's IP here, as sometimes this.session.close() is already
// invoked before tearDown(), and session channel is null in this case, which leads to unuseful
// log information
LOG.info("BMP Session with remote router {} ({}) went down.", this.routerIp, this.session);
this.session = null;
final Iterator<BmpRouterPeer> it = this.peers.values().iterator();
try {
while (it.hasNext()) {
it.next().close();
it.remove();
}
this.domTxChain.close();
} catch (final Exception e) {
LOG.error("Failed to properly close BMP application.", e);
} finally {
// as the routerId is the same for both connection
if (isDatastoreWritable()) {
try {
// it means the session was closed before it was written to datastore
final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.routerYangIId);
wTx.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.error("Failed to remove BMP router data from DS.", e);
}
this.sessionManager.removeSessionListener(this);
}
}
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class BmpRouterImpl method createRouterEntry.
private synchronized void createRouterEntry() {
Preconditions.checkState(isDatastoreWritable());
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)).withChild(ImmutableNodes.leafNode(ROUTER_ID_QNAME, this.routerIp)).withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, DOWN)).withChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).build());
wTx.submit();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method onPeerDown.
private synchronized void onPeerDown() {
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.peerYangIId);
wTx.submit();
close();
}
Aggregations