use of org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer in project bgpcep by opendaylight.
the class BmpRouterImpl method onPeerUp.
private synchronized void onPeerUp(final PeerUpNotification peerUp) {
final PeerId peerId = getPeerIdFromOpen(peerUp.getReceivedOpen());
if (!getPeer(peerId).isPresent()) {
final BmpRouterPeer peer = BmpRouterPeerImpl.createRouterPeer(this.domTxChain, this.peersYangIId, peerUp, this.extensions, this.tree, peerId);
this.peers.put(peerId, peer);
LOG.debug("Router {}: Peer {} goes up.", this.routerIp, peerId.getValue());
} else {
LOG.debug("Peer: {} for Router: {} already exists.", peerId.getValue(), this.routerIp);
}
}
use of org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer in project bgpcep by opendaylight.
the class BmpRouterImpl method delegateToPeer.
private synchronized void delegateToPeer(final Notification perPeerMessage) {
final PeerId peerId = getPeerId((PeerHeader) perPeerMessage);
final Optional<BmpRouterPeer> maybePeer = getPeer(peerId);
if (maybePeer.isPresent()) {
maybePeer.get().onPeerMessage(perPeerMessage);
if (perPeerMessage instanceof PeerDownNotification) {
this.peers.remove(peerId);
LOG.debug("Router {}: Peer {} removed.", this.routerIp, peerId.getValue());
}
} else {
LOG.debug("Peer: {} for Router: {} was not found.", peerId.getValue(), this.routerIp);
}
}
use of org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer 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);
}
}
}
Aggregations