Remove next hop location from resolved route
The next hop location should be obtained from host service
Change-Id: I8652e6b8b1367097ffbfcb1651538c34819f67d6
diff --git a/apps/route-service/api/src/main/java/org/onosproject/routeservice/ResolvedRoute.java b/apps/route-service/api/src/main/java/org/onosproject/routeservice/ResolvedRoute.java
index 828827d..1795e1e 100644
--- a/apps/route-service/api/src/main/java/org/onosproject/routeservice/ResolvedRoute.java
+++ b/apps/route-service/api/src/main/java/org/onosproject/routeservice/ResolvedRoute.java
@@ -29,6 +29,7 @@
/**
* Represents a route with the next hop MAC address resolved.
*/
+// TODO Remove location from ResolvedRoute
public class ResolvedRoute {
private final Route route;
@@ -42,7 +43,9 @@
* @param route input route
* @param nextHopMac next hop MAC address
* @param location connect point where the next hop connects to
+ * @deprecated in 1.11 ("Loon")
*/
+ @Deprecated
public ResolvedRoute(Route route, MacAddress nextHopMac, ConnectPoint location) {
this(route, nextHopMac, VlanId.NONE, location);
}
@@ -54,7 +57,9 @@
* @param nextHopMac next hop MAC address
* @param nextHopVlan next hop VLAN ID
* @param location connect point where the next hop connects to
+ * @deprecated in 1.11 ("Loon")
*/
+ @Deprecated
public ResolvedRoute(Route route, MacAddress nextHopMac, VlanId nextHopVlan,
ConnectPoint location) {
this.route = route;
@@ -63,6 +68,31 @@
this.location = location;
}
+
+ /**
+ * Creates a new resolved route.
+ *
+ * @param route input route
+ * @param nextHopMac next hop MAC address
+ */
+ public ResolvedRoute(Route route, MacAddress nextHopMac) {
+ this(route, nextHopMac, VlanId.NONE);
+ }
+
+ /**
+ * Creates a new resolved route.
+ *
+ * @param route input route
+ * @param nextHopMac next hop MAC address
+ * @param nextHopVlan next hop VLAN ID
+ */
+ public ResolvedRoute(Route route, MacAddress nextHopMac, VlanId nextHopVlan) {
+ this.route = route;
+ this.nextHopMac = nextHopMac;
+ this.nextHopVlan = nextHopVlan;
+ this.location = null;
+ }
+
/**
* Returns the original route.
*
@@ -112,7 +142,9 @@
* Returns the next hop location.
*
* @return connect point where the next hop attaches to
+ * @deprecated in 1.11 ("Loon")
*/
+ @Deprecated
public ConnectPoint location() {
return location;
}
diff --git a/apps/route-service/app/src/main/java/org/onosproject/routeservice/impl/RouteManager.java b/apps/route-service/app/src/main/java/org/onosproject/routeservice/impl/RouteManager.java
index e5db364..8914a1e 100644
--- a/apps/route-service/app/src/main/java/org/onosproject/routeservice/impl/RouteManager.java
+++ b/apps/route-service/app/src/main/java/org/onosproject/routeservice/impl/RouteManager.java
@@ -197,7 +197,7 @@
private ResolvedRoute tryResolve(Route route) {
ResolvedRoute resolvedRoute = resolve(route);
if (resolvedRoute == null) {
- resolvedRoute = new ResolvedRoute(route, null, null);
+ resolvedRoute = new ResolvedRoute(route, null, null, null);
}
return resolvedRoute;
}
@@ -238,13 +238,9 @@
hostService.startMonitoringIp(route.nextHop());
Set<Host> hosts = hostService.getHostsByIp(route.nextHop());
- Optional<Host> host = hosts.stream().findFirst();
- if (host.isPresent()) {
- return new ResolvedRoute(route, host.get().mac(), host.get().vlan(),
- host.get().location());
- } else {
- return null;
- }
+ return hosts.stream().findFirst()
+ .map(host -> new ResolvedRoute(route, host.mac(), host.vlan(), host.location()))
+ .orElse(null);
}
private ResolvedRoute decide(ResolvedRoute route1, ResolvedRoute route2) {