use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.event.EventData 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);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.event.EventData in project genius by opendaylight.
the class AlivenessMonitor method publishNotification.
void publishNotification(final Long monitorId, final LivenessState state) {
LOG.debug("Sending notification for id {} - state {}", monitorId, state);
EventData data = new EventDataBuilder().setMonitorId(monitorId).setMonitorState(state).build();
MonitorEvent event = new MonitorEventBuilder().setEventData(data).build();
final ListenableFuture<?> eventFuture = notificationPublishService.offerNotification(event);
Futures.addCallback(eventFuture, new FutureCallback<Object>() {
@Override
public void onFailure(Throwable error) {
LOG.warn("Error in notifying listeners for id {} - state {}", monitorId, state, error);
}
@Override
public void onSuccess(Object arg) {
LOG.trace("Successful in notifying listeners for id {} - state {}", monitorId, state);
}
}, callbackExecutorService);
}
Aggregations