Search in sources :

Example 21 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project bgpcep by opendaylight.

the class BGPSessionImplTest method testHandleOpenMsg.

@Test
public void testHandleOpenMsg() throws BGPDocumentedException {
    this.bgpSession.handleMessage(this.classicOpen);
    assertEquals(State.IDLE, this.bgpSession.getState());
    assertEquals(1, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(0) instanceof Notify);
    final Notify error = (Notify) this.receivedMsgs.get(0);
    assertEquals(BGPError.FSM_ERROR.getCode(), error.getErrorCode());
    assertEquals(BGPError.FSM_ERROR.getSubcode(), error.getErrorSubcode());
    verify(this.speakerListener).close();
}
Also used : Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify) Test(org.junit.Test)

Example 22 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project bgpcep by opendaylight.

the class FSMTest method sendNotification.

@Test
public void sendNotification() {
    this.clientSession.channelActive(null);
    this.clientSession.handleMessage(this.classicOpen);
    this.clientSession.handleMessage(new KeepaliveBuilder().build());
    assertEquals(this.clientSession.getState(), BGPClientSessionNegotiator.State.FINISHED);
    this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(Uint16.valueOf(30)).setHoldTimer(Uint16.valueOf(3)).setVersion(new ProtocolVersion(Uint8.valueOf(4))).build());
    assertEquals(3, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(2) instanceof Notify);
    final Notification m = this.receivedMsgs.get(2);
    assertEquals(BGPError.FSM_ERROR.getCode(), ((Notify) m).getErrorCode());
    assertEquals(BGPError.FSM_ERROR.getSubcode(), ((Notify) m).getErrorSubcode());
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder) Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.KeepaliveBuilder) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.ProtocolVersion) Notification(org.opendaylight.yangtools.yang.binding.Notification) Test(org.junit.Test)

Example 23 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project netvirt by opendaylight.

the class VpnInterfaceManager method processVpnInterfaceUp.

// "Unconditional wait" and "Wait not in loop" wrt the VpnNotifyTask below - suppressing the FB violation -
// see comments below.
@SuppressFBWarnings({ "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP" })
protected void processVpnInterfaceUp(final BigInteger dpId, VpnInterface vpnInterface, final String primaryRd, final int lportTag, boolean isInterfaceUp, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn, WriteTransaction writeInvTxn, Interface interfaceState, final String vpnName) {
    final String interfaceName = vpnInterface.getName();
    Optional<VpnInterfaceOpDataEntry> optOpVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, interfaceName, vpnName);
    VpnInterfaceOpDataEntry opVpnInterface = optOpVpnInterface.isPresent() ? optOpVpnInterface.get() : null;
    boolean isBgpVpnInternetVpn = VpnUtil.isBgpVpnInternet(dataBroker, vpnName);
    if (!isInterfaceUp) {
        LOG.info("processVpnInterfaceUp: Binding vpn service to interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
        long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
        if (vpnId == VpnConstants.INVALID_ID) {
            LOG.warn("processVpnInterfaceUp: VpnInstance to VPNId mapping not available for VpnName {}" + " processing vpninterface {} on dpn {}, bailing out now.", vpnName, interfaceName, dpId);
            return;
        }
        boolean waitForVpnInterfaceOpRemoval = false;
        if (opVpnInterface != null && !opVpnInterface.isScheduledForRemove()) {
            String opVpnName = opVpnInterface.getVpnInstanceName();
            String primaryInterfaceIp = null;
            if (opVpnName.equals(vpnName)) {
                // Please check if the primary VRF Entry does not exist for VPNInterface
                // If so, we have to process ADD, as this might be a DPN Restart with Remove and Add triggered
                // back to back
                // However, if the primary VRF Entry for this VPNInterface exists, please continue bailing out !
                List<Adjacency> adjs = VpnUtil.getAdjacenciesForVpnInterfaceFromConfig(dataBroker, interfaceName);
                if (adjs == null) {
                    LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} failed as adjacencies" + " for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
                    return;
                }
                for (Adjacency adj : adjs) {
                    if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                        primaryInterfaceIp = adj.getIpAddress();
                        break;
                    }
                }
                if (primaryInterfaceIp == null) {
                    LOG.error("processVpnInterfaceUp: VPN Interface {} addition on dpn {} for vpn {} failed" + " as primary adjacency for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
                    return;
                }
                // Get the rd of the vpn instance
                VrfEntry vrf = VpnUtil.getVrfEntry(dataBroker, primaryRd, primaryInterfaceIp);
                if (vrf != null) {
                    LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} already provisioned ," + " bailing out from here.", interfaceName, dpId, vpnName);
                    return;
                }
                waitForVpnInterfaceOpRemoval = true;
            } else {
                LOG.error("processVpnInterfaceUp: vpn interface {} to go to configured vpn {} on dpn {}," + " but in operational vpn {}", interfaceName, vpnName, dpId, opVpnName);
            }
        }
        if (!waitForVpnInterfaceOpRemoval) {
            // Add the VPNInterface and quit
            vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
            true);
            processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState);
            if (!isBgpVpnInternetVpn) {
                VpnUtil.bindService(vpnName, interfaceName, dataBroker, false, /*isTunnelInterface*/
                jobCoordinator);
            }
            LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
            if (interfaceManager.isExternalInterface(interfaceName)) {
                processExternalVpnInterface(interfaceName, vpnName, vpnId, dpId, lportTag, writeInvTxn, NwConstants.ADD_FLOW);
            }
            return;
        }
        // FIB didn't get a chance yet to clean up this VPNInterface
        // Let us give it a chance here !
        LOG.info("processVpnInterfaceUp: Trying to add VPN Interface {} on dpn {} for vpn {}," + " but waiting for FIB to clean up! ", interfaceName, dpId, vpnName);
        try {
            Runnable notifyTask = new VpnNotifyTask();
            synchronized (notifyTask) {
                // Per FB's "Unconditional wait" violation, the code should really verify that the condition it
                // intends to wait for is not already satisfied before calling wait. However the VpnNotifyTask is
                // published here while holding the lock on it so this path will hit the wait before notify can be
                // invoked.
                vpnIntfMap.put(interfaceName, notifyTask);
                try {
                    notifyTask.wait(VpnConstants.MAX_WAIT_TIME_IN_MILLISECONDS);
                } catch (InterruptedException e) {
                // Ignored
                }
            }
        } finally {
            vpnIntfMap.remove(interfaceName);
        }
        if (opVpnInterface != null) {
            LOG.warn("processVpnInterfaceUp: VPN Interface {} removal on dpn {} for vpn {}" + " by FIB did not complete on time," + " bailing addition ...", interfaceName, dpId, vpnName);
            VpnUtil.unsetScheduledToRemoveForVpnInterface(txRunner, interfaceName);
            return;
        }
        // VPNInterface got removed, proceed with Add
        LOG.info("processVpnInterfaceUp: Continuing to plumb vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
        vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
        true);
        processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState);
        if (!isBgpVpnInternetVpn) {
            VpnUtil.bindService(vpnName, interfaceName, dataBroker, false, /*isTunnelInterface*/
            jobCoordinator);
        }
        LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {} after waiting for" + " FIB to clean up", interfaceName, dpId, vpnName);
        if (interfaceManager.isExternalInterface(interfaceName)) {
            processExternalVpnInterface(interfaceName, vpnName, vpnId, dpId, lportTag, writeInvTxn, NwConstants.ADD_FLOW);
        }
    } else {
        // Interface is retained in the DPN, but its Link Up.
        // Advertise prefixes again for this interface to BGP
        InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName());
        InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
        advertiseAdjacenciesForVpnToBgp(primaryRd, dpId, vpnInterfaceOpIdentifier, vpnName, interfaceName);
        // Perform similar operation as interface add event for extraroutes.
        InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
        Optional<Adjacencies> optAdjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
        if (!optAdjacencies.isPresent()) {
            LOG.trace("No config adjacencies present for vpninterface {}", vpnInterface);
            return;
        }
        List<Adjacency> adjacencies = optAdjacencies.get().getAdjacency();
        for (Adjacency adjacency : adjacencies) {
            if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                continue;
            }
            // if BGPVPN Internet, filter only IPv6 Adjacencies
            if (isBgpVpnInternetVpn && !VpnUtil.isAdjacencyEligibleToVpnInternet(dataBroker, adjacency)) {
                continue;
            }
            addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency, dpId, writeOperTxn, writeConfigTxn);
        }
    }
}
Also used : Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 24 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project cxf by apache.

the class JmsPublisher method notify.

@Override
public void notify(NotificationMessageHolderType messageHolder) {
    Session session = null;
    try {
        Topic topic = topicConverter.toActiveMQTopic(messageHolder.getTopic());
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(topic);
        Notify notify = new Notify();
        notify.getNotificationMessage().add(messageHolder);
        StringWriter writer = new StringWriter();
        jaxbContext.createMarshaller().marshal(notify, writer);
        Message message = session.createTextMessage(writer.toString());
        producer.send(message);
    } catch (JMSException | JAXBException | InvalidTopicException e) {
        LOGGER.log(Level.WARNING, "Error dispatching message", e);
    } finally {
        if (session != null) {
            try {
                session.close();
            } catch (JMSException e) {
                LOGGER.log(Level.FINE, "Error closing session", e);
            }
        }
    }
}
Also used : StringWriter(java.io.StringWriter) Message(javax.jms.Message) Notify(org.oasis_open.docs.wsn.b_2.Notify) JAXBException(javax.xml.bind.JAXBException) JMSException(javax.jms.JMSException) MessageProducer(javax.jms.MessageProducer) Topic(javax.jms.Topic) Session(javax.jms.Session)

Example 25 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project cxf by apache.

the class JmsPullPoint method store.

@Override
protected void store(NotificationMessageHolderType messageHolder) {
    try {
        initSession();
        Notify notify = new Notify();
        notify.getNotificationMessage().add(messageHolder);
        StringWriter writer = new StringWriter();
        jaxbContext.createMarshaller().marshal(notify, writer);
        synchronized (producerSession) {
            Message message = producerSession.createTextMessage(writer.toString());
            producer.send(message);
        }
    } catch (JMSException e) {
        LOGGER.log(Level.WARNING, "Error storing message", e);
        closeSession();
    } catch (JAXBException e) {
        LOGGER.log(Level.WARNING, "Error storing message", e);
    }
}
Also used : StringWriter(java.io.StringWriter) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) Notify(org.oasis_open.docs.wsn.b_2.Notify) JAXBException(javax.xml.bind.JAXBException) JMSException(javax.jms.JMSException)

Aggregations

Test (org.junit.Test)16 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)12 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)8 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 ArrayList (java.util.ArrayList)5 JAXBException (javax.xml.bind.JAXBException)5 Notify (org.oasis_open.docs.wsn.b_2.Notify)5 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)5 JMSException (javax.jms.JMSException)4 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 Message (javax.jms.Message)3 TextMessage (javax.jms.TextMessage)3 NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)3 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)3 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)3 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder)3 Optional (com.google.common.base.Optional)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ByteBuf (io.netty.buffer.ByteBuf)2