Remove dependencies from EVPN route system on unicast route system.
The route system is moving to an app, so EVPN code in the incubator
can't depend on it. I implemented an EvpnRouteTableId to remove this
dependency.
Change-Id: Id9af9fc0e0c680add1e061d0628ffdbd2a23dbde
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/DistributedEvpnRouteStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/DistributedEvpnRouteStore.java
index 49356b6..b4526e2 100755
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/DistributedEvpnRouteStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/DistributedEvpnRouteStore.java
@@ -30,8 +30,8 @@
import org.onosproject.incubator.net.routing.EvpnRouteSet;
import org.onosproject.incubator.net.routing.EvpnRouteStore;
import org.onosproject.incubator.net.routing.EvpnRouteStoreDelegate;
+import org.onosproject.incubator.net.routing.EvpnRouteTableId;
import org.onosproject.incubator.net.routing.EvpnTable;
-import org.onosproject.incubator.net.routing.RouteTableId;
import org.onosproject.store.AbstractStore;
import org.onosproject.store.service.DistributedSet;
import org.onosproject.store.service.Serializer;
@@ -67,18 +67,18 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
public StorageService storageService;
- private static final RouteTableId EVPN_IPV4 = new RouteTableId("evpn_ipv4");
- private static final RouteTableId EVPN_IPV6 = new RouteTableId("evpn_ipv6");
+ private static final EvpnRouteTableId EVPN_IPV4 = new EvpnRouteTableId("evpn_ipv4");
+ private static final EvpnRouteTableId EVPN_IPV6 = new EvpnRouteTableId("evpn_ipv6");
- private final SetEventListener<RouteTableId> masterRouteTableListener =
+ private final SetEventListener<EvpnRouteTableId> masterRouteTableListener =
new MasterRouteTableListener();
private final EvpnRouteStoreDelegate ourDelegate = new
InternalEvpnRouteStoreDelegate();
// Stores the route tables that have been created
- public DistributedSet<RouteTableId> masterRouteTable;
+ public DistributedSet<EvpnRouteTableId> masterRouteTable;
// Local memory map to store route table object
- public Map<RouteTableId, EvpnTable> routeTables;
+ public Map<EvpnRouteTableId, EvpnTable> routeTables;
private ExecutorService executor;
@@ -92,10 +92,10 @@
executor = Executors.newSingleThreadExecutor(groupedThreads("onos/route", "store", log));
KryoNamespace masterRouteTableSerializer = KryoNamespace.newBuilder()
- .register(RouteTableId.class)
+ .register(EvpnRouteTableId.class)
.build();
- masterRouteTable = storageService.<RouteTableId>setBuilder()
+ masterRouteTable = storageService.<EvpnRouteTableId>setBuilder()
.withName("onos-master-route-table")
.withSerializer(Serializer.using(masterRouteTableSerializer))
.build()
@@ -135,12 +135,12 @@
}
@Override
- public Set<RouteTableId> getRouteTables() {
+ public Set<EvpnRouteTableId> getRouteTables() {
return ImmutableSet.copyOf(masterRouteTable);
}
@Override
- public Collection<EvpnRouteSet> getRoutes(RouteTableId table) {
+ public Collection<EvpnRouteSet> getRoutes(EvpnRouteTableId table) {
EvpnTable routeTable = routeTables.get(table);
if (routeTable == null) {
return Collections.emptySet();
@@ -154,12 +154,12 @@
return getDefaultRouteTable(ip).getRoutesForNextHop(ip);
}
- private void createRouteTable(RouteTableId tableId) {
+ private void createRouteTable(EvpnRouteTableId tableId) {
routeTables.computeIfAbsent(tableId, id -> new EvpnRouteTable(id,
ourDelegate, storageService, executor));
}
- private void destroyRouteTable(RouteTableId tableId) {
+ private void destroyRouteTable(EvpnRouteTableId tableId) {
EvpnTable table = routeTables.remove(tableId);
if (table != null) {
table.destroy();
@@ -171,7 +171,7 @@
}
private EvpnTable getDefaultRouteTable(IpAddress ip) {
- RouteTableId routeTableId = (ip.isIp4()) ? EVPN_IPV4 : EVPN_IPV6;
+ EvpnRouteTableId routeTableId = (ip.isIp4()) ? EVPN_IPV4 : EVPN_IPV6;
return routeTables.getOrDefault(routeTableId, EmptyEvpnRouteTable
.instance());
}
@@ -185,9 +185,9 @@
}
}
- private class MasterRouteTableListener implements SetEventListener<RouteTableId> {
+ private class MasterRouteTableListener implements SetEventListener<EvpnRouteTableId> {
@Override
- public void event(SetEvent<RouteTableId> event) {
+ public void event(SetEvent<EvpnRouteTableId> event) {
switch (event.type()) {
case ADD:
executor.execute(() -> createRouteTable(event.entry()));
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EmptyEvpnRouteTable.java b/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EmptyEvpnRouteTable.java
index fc59649..aa56d71 100755
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EmptyEvpnRouteTable.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EmptyEvpnRouteTable.java
@@ -20,8 +20,8 @@
import org.onosproject.incubator.net.routing.EvpnPrefix;
import org.onosproject.incubator.net.routing.EvpnRoute;
import org.onosproject.incubator.net.routing.EvpnRouteSet;
+import org.onosproject.incubator.net.routing.EvpnRouteTableId;
import org.onosproject.incubator.net.routing.EvpnTable;
-import org.onosproject.incubator.net.routing.RouteTableId;
import java.util.Collection;
import java.util.Collections;
@@ -31,7 +31,7 @@
*/
public final class EmptyEvpnRouteTable implements EvpnTable {
- private final RouteTableId id = new RouteTableId("empty");
+ private final EvpnRouteTableId id = new EvpnRouteTableId("empty");
private static final EmptyEvpnRouteTable INSTANCE = new EmptyEvpnRouteTable();
@@ -58,7 +58,7 @@
}
@Override
- public RouteTableId id() {
+ public EvpnRouteTableId id() {
return id;
}
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EvpnRouteTable.java b/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EvpnRouteTable.java
index 9fd8798..33c8f96 100755
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EvpnRouteTable.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/routing/impl/EvpnRouteTable.java
@@ -25,11 +25,10 @@
import org.onosproject.incubator.net.routing.EvpnRoute;
import org.onosproject.incubator.net.routing.EvpnRouteSet;
import org.onosproject.incubator.net.routing.EvpnRouteStoreDelegate;
+import org.onosproject.incubator.net.routing.EvpnRouteTableId;
import org.onosproject.incubator.net.routing.EvpnTable;
import org.onosproject.incubator.net.routing.Label;
-import org.onosproject.incubator.net.routing.Route;
import org.onosproject.incubator.net.routing.RouteDistinguisher;
-import org.onosproject.incubator.net.routing.RouteTableId;
import org.onosproject.incubator.net.routing.VpnRouteTarget;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
@@ -55,7 +54,7 @@
*/
public class EvpnRouteTable implements EvpnTable {
- private final RouteTableId id;
+ private final EvpnRouteTableId id;
private final ConsistentMap<EvpnPrefix, Set<EvpnRoute>> routes;
private final EvpnRouteStoreDelegate delegate;
private final ExecutorService executor;
@@ -71,7 +70,7 @@
* @param storageService storage service
* @param executor executor service
*/
- public EvpnRouteTable(RouteTableId id, EvpnRouteStoreDelegate delegate,
+ public EvpnRouteTable(EvpnRouteTableId id, EvpnRouteStoreDelegate delegate,
StorageService storageService, ExecutorService executor) {
this.delegate = checkNotNull(delegate);
this.id = checkNotNull(id);
@@ -103,8 +102,6 @@
KryoNamespace routeTableSerializer = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(KryoNamespaces.MISC)
- .register(Route.class)
- .register(Route.Source.class)
.register(EvpnRoute.class)
.register(EvpnPrefix.class)
.register(RouteDistinguisher.class)
@@ -114,7 +111,7 @@
.register(IpAddress.class)
.register(VpnRouteTarget.class)
.register(Label.class)
- .register(RouteTableId.class)
+ .register(EvpnRouteTableId.class)
.build();
return storageService.<EvpnPrefix, Set<EvpnRoute>>consistentMapBuilder()
.withName("onos-evpn-routes-" + id.name())
@@ -124,7 +121,7 @@
}
@Override
- public RouteTableId id() {
+ public EvpnRouteTableId id() {
return id;
}