Search in sources :

Example 1 with PeerDownNotification

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.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.isLocalSystemClosed()) {
        if (peerDown.getData() instanceof FsmEventCode) {
            ByteBufWriteUtil.writeUnsignedByte(REASON_TWO.getValue(), buffer);
            ByteBufWriteUtil.writeUnsignedShort(((FsmEventCode) peerDown.getData()).getFsmEventCode(), buffer);
        } else if (peerDown.getData() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.Notification) {
            ByteBufWriteUtil.writeUnsignedByte(REASON_ONE.getValue(), buffer);
            serializePDU(peerDown.getData(), buffer);
        }
    } else {
        if (peerDown.getData() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.Notification) {
            ByteBufWriteUtil.writeUnsignedByte(REASON_THREE.getValue(), buffer);
            serializePDU(peerDown.getData(), buffer);
        } else {
            ByteBufWriteUtil.writeUnsignedByte(REASON_FOUR.getValue(), buffer);
        }
    }
}
Also used : PeerDownNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotification) Preconditions(com.google.common.base.Preconditions) PeerDownNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotification) Notification(org.opendaylight.yangtools.yang.binding.Notification) FsmEventCode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.FsmEventCode)

Example 2 with PeerDownNotification

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.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);
    }
}
Also used : PeerDownNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotification) BmpRouterPeer(org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId)

Example 3 with PeerDownNotification

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.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();
}
Also used : PeerUpNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotificationBuilder) PeerDownNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotificationBuilder) NotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.NotificationBuilder) PeerDownNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotificationBuilder)

Example 4 with PeerDownNotification

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.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);
}
Also used : TestUtil.createPeerDownNotification(org.opendaylight.protocol.bmp.parser.message.TestUtil.createPeerDownNotification) PeerDownNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotification) Test(org.junit.Test)

Example 5 with PeerDownNotification

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.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);
}
Also used : TestUtil.createPeerDownNotification(org.opendaylight.protocol.bmp.parser.message.TestUtil.createPeerDownNotification) PeerDownNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotification) Test(org.junit.Test)

Aggregations

PeerDownNotification (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotification)4 Test (org.junit.Test)2 TestUtil.createPeerDownNotification (org.opendaylight.protocol.bmp.parser.message.TestUtil.createPeerDownNotification)2 Preconditions (com.google.common.base.Preconditions)1 BmpRouterPeer (org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer)1 PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId)1 PeerDownNotificationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerDownNotificationBuilder)1 PeerUpNotificationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotificationBuilder)1 FsmEventCode (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.FsmEventCode)1 NotificationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.NotificationBuilder)1 Notification (org.opendaylight.yangtools.yang.binding.Notification)1