Search in sources :

Example 1 with HostProbe

use of org.onosproject.net.host.HostProbe in project onos by opennetworkinglab.

the class DefaultHostProbingProvider method processEvent.

@Override
public void processEvent(HostProbingEvent event) {
    probeEventHandler.execute(() -> {
        log.debug("Receiving HostProbingEvent {}", event);
        HostProbe hostProbe = event.subject();
        switch(event.type()) {
            case PROBE_REQUESTED:
                // Do nothing
                break;
            case PROBE_TIMEOUT:
                // Retry probe until PROBE_FAIL
                // TODO Only retry DISCOVER probes
                probeHostInternal(hostProbe, hostProbe.connectPoint(), hostProbe.mode(), hostProbe.probeMac(), hostProbe.retry());
                break;
            case PROBE_FAIL:
                // Remove this location if this is a verify probe.
                if (hostProbe.mode() == ProbeMode.VERIFY) {
                    ConnectPoint oldConnectPoint = hostProbe.connectPoint();
                    if (!oldConnectPoint.port().hasName()) {
                        oldConnectPoint = translateSwitchPort(oldConnectPoint);
                    }
                    providerService.removeLocationFromHost(hostProbe.id(), new HostLocation(oldConnectPoint, 0L));
                }
                break;
            case PROBE_COMPLETED:
                // Add this location if this is a discover probe.
                if (hostProbe.mode() == ProbeMode.DISCOVER) {
                    ConnectPoint newConnectPoint = hostProbe.connectPoint();
                    if (!newConnectPoint.port().hasName()) {
                        newConnectPoint = translateSwitchPort(newConnectPoint);
                    }
                    providerService.addLocationToHost(hostProbe.id(), new HostLocation(newConnectPoint, System.currentTimeMillis()));
                }
                break;
            default:
                log.warn("Unknown HostProbingEvent type: {}", event.type());
        }
    });
}
Also used : HostProbe(org.onosproject.net.host.HostProbe) HostLocation(org.onosproject.net.HostLocation) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)1 HostLocation (org.onosproject.net.HostLocation)1 HostProbe (org.onosproject.net.host.HostProbe)1