use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification in project bgpcep by opendaylight.
the class PeerDownHandler method serializeMessageBody.
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
super.serializeMessageBody(message, buffer);
Preconditions.checkArgument(message instanceof PeerDownNotification, "An instance of PeerDownNotification is required");
final PeerDownNotification peerDown = (PeerDownNotification) message;
if (peerDown.getLocalSystemClosed()) {
if (peerDown.getData() instanceof FsmEventCode) {
buffer.writeByte(REASON_TWO.getValue());
ByteBufUtils.writeOrZero(buffer, ((FsmEventCode) peerDown.getData()).getFsmEventCode());
} else if (peerDown.getData() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.down.data.Notification) {
buffer.writeByte(REASON_ONE.getValue());
serializePDU(peerDown.getData(), buffer);
}
} else {
if (peerDown.getData() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.down.data.Notification) {
buffer.writeByte(REASON_THREE.getValue());
serializePDU(peerDown.getData(), buffer);
} else {
buffer.writeByte(REASON_FOUR.getValue());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification in project bgpcep by opendaylight.
the class TestUtil method createPeerDownNotification.
public static PeerDownNotification createPeerDownNotification(final Ipv4Address bgpId) {
final NotificationBuilder notifBuilder = new NotificationBuilder().setNotification(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.notification.NotificationBuilder().setErrorCode((short) 1).setErrorSubcode((short) 1).build());
final PeerDownNotificationBuilder peerDownNotifBuilder = new PeerDownNotificationBuilder().setData(notifBuilder.build()).setLocalSystemClosed(true).setPeerHeader(TestUtil.createPeerHeader(bgpId));
return peerDownNotifBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification in project bgpcep by opendaylight.
the class PeerDownHandlerTest method testParsePeerDownNotificationFSM.
@Test
public void testParsePeerDownNotificationFSM() throws BmpDeserializationException {
final PeerDownNotification parsedPeerDownFSM = (PeerDownNotification) getBmpMessageRegistry().parseMessage(Unpooled.copiedBuffer(PEER_DOWN_FSM_DATA));
assertEquals(createPeerDownFSM(), parsedPeerDownFSM);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification in project bgpcep by opendaylight.
the class PeerDownHandlerTest method testParsePeerDownNotification.
@Test
public void testParsePeerDownNotification() throws BmpDeserializationException {
final PeerDownNotification parsedPeerDownNotif = (PeerDownNotification) getBmpMessageRegistry().parseMessage(Unpooled.copiedBuffer(PEER_DOWN_NOTIFICATION));
assertEquals(createPeerDownNotification(), parsedPeerDownNotif);
}
Aggregations