Search in sources :

Example 1 with RemoveEventData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData in project netvirt by opendaylight.

the class VpnFootprintService method publishRemoveNotification.

private void publishRemoveNotification(final BigInteger dpnId, final String vpnName, final String rd) {
    LOG.debug("publishRemoveNotification: Sending notification for remove dpn {} in vpn {} rd {} event ", dpnId, vpnName, rd);
    RemoveEventData data = new RemoveEventDataBuilder().setVpnName(vpnName).setRd(rd).setDpnId(dpnId).build();
    RemoveDpnEvent event = new RemoveDpnEventBuilder().setRemoveEventData(data).build();
    final ListenableFuture<?> eventFuture = notificationPublishService.offerNotification(event);
    Futures.addCallback(eventFuture, new FutureCallback<Object>() {

        @Override
        public void onFailure(Throwable error) {
            LOG.error("publishRemoveNotification: Error in notifying listeners for remove dpn {} in vpn {} rd {}" + " event ", dpnId, vpnName, rd, error);
        }

        @Override
        public void onSuccess(Object arg) {
            LOG.info("publishRemoveNotification: Successful in notifying listeners for remove dpn {} in vpn {}" + " rd {} event ", dpnId, vpnName, rd);
        }
    }, MoreExecutors.directExecutor());
}
Also used : RemoveDpnEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RemoveDpnEventBuilder) RemoveEventDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventDataBuilder) RemoveEventData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData) RemoveDpnEvent(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RemoveDpnEvent)

Example 2 with RemoveEventData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData in project netvirt by opendaylight.

the class DpnInVpnChangeListener method onRemoveDpnEvent.

@Override
public void onRemoveDpnEvent(RemoveDpnEvent notification) {
    RemoveEventData eventData = notification.getRemoveEventData();
    final String rd = eventData.getRd();
    final String vpnName = eventData.getVpnName();
    BigInteger dpnId = eventData.getDpnId();
    LOG.trace("Remove Dpn Event notification received for rd {} VpnName {} DpnId {}", rd, vpnName, dpnId);
    synchronized (vpnName.intern()) {
        InstanceIdentifier<VpnInstanceOpDataEntry> id = VpnUtil.getVpnInstanceOpDataIdentifier(rd);
        Optional<VpnInstanceOpDataEntry> vpnOpValue = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
        if (vpnOpValue.isPresent()) {
            VpnInstanceOpDataEntry vpnInstOpData = vpnOpValue.get();
            List<VpnToDpnList> vpnToDpnList = vpnInstOpData.getVpnToDpnList();
            boolean flushDpnsOnVpn = true;
            for (VpnToDpnList dpn : vpnToDpnList) {
                if (dpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                    flushDpnsOnVpn = false;
                    break;
                }
            }
            if (flushDpnsOnVpn) {
                WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
                deleteDpn(vpnToDpnList, rd, writeTxn);
                try {
                    writeTxn.submit().get();
                } catch (InterruptedException | ExecutionException e) {
                    LOG.error("Error removing dpnToVpnList for vpn {} ", vpnName);
                    throw new RuntimeException(e.getMessage(), e);
                }
            }
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RemoveEventData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) BigInteger(java.math.BigInteger) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

RemoveEventData (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData)2 BigInteger (java.math.BigInteger)1 ExecutionException (java.util.concurrent.ExecutionException)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 RemoveDpnEvent (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RemoveDpnEvent)1 RemoveDpnEventBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RemoveDpnEventBuilder)1 RemoveEventDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventDataBuilder)1 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)1 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)1