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());
}
});
}
Aggregations