[CORD-2223] Avoid unnecessary probing when a host moves within the same switch

Change-Id: I777234564801ab236bf48ecf04ce75aaa1061a18
This commit is contained in:
Charles Chan 2017-11-22 14:49:55 -08:00 committed by Charles Chan
parent 105736e0c0
commit 653e2ac0af

View File

@ -407,10 +407,17 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
Host existingHost = hostService.getHost(hid);
if (existingHost != null) {
Set<HostLocation> prevLocations = existingHost.locations();
newLocations.addAll(prevLocations);
if (!existingHost.locations().contains(hloc)) {
if (prevLocations.stream().noneMatch(loc -> loc.deviceId().equals(hloc.deviceId()))) {
// New location is on a device that we haven't seen before
// Could be a dual-home host. Append new location and send out the probe
newLocations.addAll(prevLocations);
probeLocations(existingHost);
} else {
// Move within the same switch
// Simply replace old location that is on the same device
prevLocations.stream().filter(loc -> !loc.deviceId().equals(hloc.deviceId()))
.forEach(newLocations::add);
}
}
}