Search in sources :

Example 1 with MonitorEvent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorEvent in project netvirt by opendaylight.

the class ArpMonitorEventListener method onMonitorEvent.

@Override
public void onMonitorEvent(MonitorEvent notification) {
    Long monitorId = notification.getEventData().getMonitorId();
    MacEntry macEntry = AlivenessMonitorUtils.getMacEntryFromMonitorId(monitorId);
    if (macEntry == null) {
        LOG.debug("No MacEntry found associated with the monitor Id {}", monitorId);
        return;
    }
    LivenessState livenessState = notification.getEventData().getMonitorState();
    if (livenessState.equals(LivenessState.Down)) {
        String vpnName = macEntry.getVpnName();
        String learntIp = macEntry.getIpAddress().getHostAddress();
        LearntVpnVipToPort vpnVipToPort = VpnUtil.getLearntVpnVipToPort(dataBroker, vpnName, learntIp);
        if (vpnVipToPort != null && macEntry.getCreatedTime().equals(vpnVipToPort.getCreationTime())) {
            jobCoordinator.enqueueJob(ArpMonitoringHandler.buildJobKey(macEntry.getIpAddress().getHostAddress(), macEntry.getVpnName()), new ArpMonitorStopTask(macEntry, dataBroker, alivenessManager));
        }
    }
}
Also used : LivenessState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)

Example 2 with MonitorEvent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorEvent 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);
}
Also used : MonitorEvent(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorEvent) EventDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.event.EventDataBuilder) MonitorEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorEventBuilder) EventData(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.event.EventData)

Aggregations

LivenessState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState)1 MonitorEvent (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorEvent)1 MonitorEventBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorEventBuilder)1 EventData (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.event.EventData)1 EventDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.event.EventDataBuilder)1 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)1