Implement host probing retry with major refactoring
- Implement probe retry
- Switch to typical core/provider design pattern for HostProbingService
and as a result decoupling the dependency between SR and HostLocationProvider
Change-Id: I33a15af580677ea376b421ac3e26f9821dcca844
diff --git a/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java b/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java
index f71c1d0..3982731 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java
@@ -27,8 +27,8 @@
import org.onosproject.net.HostLocation;
import org.onosproject.net.PortNumber;
import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostLocationProbingService.ProbeMode;
import org.onosproject.net.host.HostService;
+import org.onosproject.net.host.ProbeMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -185,6 +185,9 @@
// For each old location
Sets.difference(prevLocations, newLocations).forEach(prevLocation -> {
+ // First of all, verify each old location
+ srManager.probingService.probeHost(host, prevLocation, ProbeMode.VERIFY);
+
// Remove routing rules for old IPs
Sets.difference(prevIps, newIps).forEach(ip -> {
if (doubleTaggedHost) {
@@ -392,7 +395,7 @@
srManager.getPairDeviceId(cp.deviceId())
.ifPresent(pairDeviceId -> srManager.hostService.getConnectedHosts(pairDeviceId).stream()
.filter(host -> isHostInVlanOfPort(host, pairDeviceId, cp))
- .forEach(host -> srManager.probingService.probeHostLocation(host, cp, ProbeMode.DISCOVER))
+ .forEach(host -> srManager.probingService.probeHost(host, cp, ProbeMode.DISCOVER))
);
}
}
@@ -435,7 +438,7 @@
.filter(i -> !i.connectPoint().port().equals(pairRemotePort))
.forEach(i -> {
log.debug("Probing host {} on pair device {}", host.id(), i.connectPoint());
- srManager.probingService.probeHostLocation(host, i.connectPoint(), ProbeMode.DISCOVER);
+ srManager.probingService.probeHost(host, i.connectPoint(), ProbeMode.DISCOVER);
});
}
diff --git a/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 317e7f4..52ca18e 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -77,7 +77,7 @@
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.host.HostEvent;
import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostLocationProbingService;
+import org.onosproject.net.host.HostProbingService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.InterfaceIpAddress;
import org.onosproject.net.intent.WorkPartitionService;
@@ -186,7 +186,7 @@
HostService hostService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- HostLocationProbingService probingService;
+ HostProbingService probingService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
public DeviceService deviceService;
diff --git a/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java b/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java
index 26420ac..6783da3 100644
--- a/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java
+++ b/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java
@@ -28,7 +28,7 @@
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.net.host.HostLocationProbingService;
+import org.onosproject.net.host.ProbeMode;
import org.onosproject.net.intf.Interface;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultHost;
@@ -182,7 +182,7 @@
private static final Set<Interface> INTERFACES = Sets.newHashSet(INTF11, INTF12, INTF13, INTF21,
INTF22, INTF31, INTF32, INTF39, INTF41, INTF49);
- private MockLocationProbingService mockLocationProbingService;
+ private MockHostProbingService mockLocationProbingService;
@Before
public void setUp() throws Exception {
@@ -218,7 +218,7 @@
srManager.mastershipService = new MockMastershipService(LOCAL_DEVICES);
srManager.hostService = new MockHostService(HOSTS);
srManager.cfgService = mockNetworkConfigRegistry;
- mockLocationProbingService = new MockLocationProbingService();
+ mockLocationProbingService = new MockHostProbingService();
srManager.probingService = mockLocationProbingService;
srManager.linkHandler = new MockLinkHandler(srManager);
@@ -351,7 +351,7 @@
assertEquals(P1, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV3, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
assertEquals(P9, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV4, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
// Expect probe to be sent out on pair device
- assertTrue(mockLocationProbingService.verifyProbe(host1, CP41, HostLocationProbingService.ProbeMode.DISCOVER));
+ assertTrue(mockLocationProbingService.verifyProbe(host1, CP41, ProbeMode.DISCOVER));
// Add the second location of dual-homed host
// Expect: no longer use the pair link
@@ -753,7 +753,7 @@
assertEquals(P1, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV3, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
assertEquals(P9, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV4, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
// Expect probe to be sent out on pair device
- assertTrue(mockLocationProbingService.verifyProbe(host2, CP41, HostLocationProbingService.ProbeMode.DISCOVER));
+ assertTrue(mockLocationProbingService.verifyProbe(host2, CP41, ProbeMode.DISCOVER));
// Discover location
// Expect: cancel all redirections
diff --git a/app/src/test/java/org/onosproject/segmentrouting/MockLocationProbingService.java b/app/src/test/java/org/onosproject/segmentrouting/MockHostProbingService.java
similarity index 88%
rename from app/src/test/java/org/onosproject/segmentrouting/MockLocationProbingService.java
rename to app/src/test/java/org/onosproject/segmentrouting/MockHostProbingService.java
index b0cdf43..807db0c 100644
--- a/app/src/test/java/org/onosproject/segmentrouting/MockLocationProbingService.java
+++ b/app/src/test/java/org/onosproject/segmentrouting/MockHostProbingService.java
@@ -19,12 +19,13 @@
import com.google.common.collect.Lists;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Host;
-import org.onosproject.net.host.HostLocationProbingService;
+import org.onosproject.net.host.HostProbingService;
+import org.onosproject.net.host.ProbeMode;
import java.util.List;
import java.util.Objects;
-public class MockLocationProbingService implements HostLocationProbingService {
+public class MockHostProbingService implements HostProbingService {
List<Probe> probes;
private class Probe {
@@ -58,7 +59,7 @@
}
}
- MockLocationProbingService() {
+ MockHostProbingService() {
probes = Lists.newArrayList();
}
@@ -68,7 +69,7 @@
}
@Override
- public void probeHostLocation(Host host, ConnectPoint connectPoint, ProbeMode probeMode) {
+ public void probeHost(Host host, ConnectPoint connectPoint, ProbeMode probeMode) {
probes.add(new Probe(host, connectPoint, probeMode));
}
}