public List<EvpnRoute> routesFromContainer(final EvpnRoutes container) {
return container.getEvpnRoute();
}
+
+ @Override
+ public PathId extractPathId(final EvpnRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final EvpnRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<FlowspecRoute> routesFromContainer(final FlowspecRoutes container) {
return container.getFlowspecRoute();
}
+
+ @Override
+ public PathId extractPathId(final FlowspecRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final FlowspecRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<FlowspecRoute> routesFromContainer(final FlowspecIpv6Routes container) {
return container.getFlowspecRoute();
}
+
+ @Override
+ public PathId extractPathId(final FlowspecRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final FlowspecRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<FlowspecL3vpnRoute> routesFromContainer(final FlowspecL3vpnIpv4Routes container) {
return container.getFlowspecL3vpnRoute();
}
+
+ @Override
+ public PathId extractPathId(final FlowspecL3vpnRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final FlowspecL3vpnRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<FlowspecL3vpnRoute> routesFromContainer(final FlowspecL3vpnIpv6Routes container) {
return container.getFlowspecL3vpnRoute();
}
+
+ @Override
+ public PathId extractPathId(final FlowspecL3vpnRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final FlowspecL3vpnRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<Ipv4Route> routesFromContainer(final Ipv4Routes container) {
return container.getIpv4Route();
}
+
+ @Override
+ public PathId extractPathId(final Ipv4RouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final Ipv4RouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<Ipv6Route> routesFromContainer(final Ipv6Routes container) {
return container.getIpv6Route();
}
+
+ @Override
+ public PathId extractPathId(final Ipv6RouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final Ipv6RouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
return container.getL3vpnMcastRoute();
}
+
+ @Override
+ public final PathId extractPathId(final L3vpnMcastRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final L3vpnMcastRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
+
abstract NodeIdentifierWithPredicates createRouteKey(UnkeyedListEntryNode l3vpn);
}
public final List<VpnRoute> routesFromContainer(final S container) {
return container.getVpnRoute();
}
+
+
+ @Override
+ public PathId extractPathId(final VpnRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public final String extractRouteKey(final VpnRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public final List<LabeledUnicastRoute> routesFromContainer(final S container) {
return container.getLabeledUnicastRoute();
}
+
+
+ @Override
+ public final PathId extractPathId(final LabeledUnicastRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public final String extractRouteKey(final LabeledUnicastRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
public List<LinkstateRoute> routesFromContainer(final LinkstateRoutes container) {
return container.getLinkstateRoute();
}
+
+ @Override
+ public PathId extractPathId(final LinkstateRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final LinkstateRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
return Collections.emptyList();
}
+
+ @Override
+ public final PathId extractPathId(final MvpnRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public final String extractRouteKey(final MvpnRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
+
abstract NodeIdentifierWithPredicates createRouteKey(UnkeyedListEntryNode mvpn);
}
public List<RouteTargetConstrainRoute> routesFromContainer(final RouteTargetConstrainRoutes container) {
return container.getRouteTargetConstrainRoute();
}
+
+ @Override
+ public PathId extractPathId(final RouteTargetConstrainRouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final RouteTargetConstrainRouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib;
private void updateRoutesEntries(final Collection<? extends DataObjectModification<?>> collection,
final RouterId routerId, final Map<RouteUpdateKey, RouteEntry<C, S, R, I>> routes) {
for (final DataObjectModification<? extends DataObject> route : collection) {
- final R newRoute = (R) route.getDataAfter();
- final R oldRoute = (R) route.getDataBefore();
- String routeKey;
- RouteEntry<C, S, R, I> entry;
- if (newRoute != null) {
- routeKey = newRoute.getRouteKey();
- entry = this.routeEntries.get(routeKey);
-
- if (entry == null) {
- entry = createEntry(routeKey);
- }
+ if (!(route.getIdentifier() instanceof InstanceIdentifier.IdentifiableItem)) {
+ LOG.debug("Route {} already deleted", route.getIdentifier());
+ return;
+ }
+ final I routeListKey = (I) ((InstanceIdentifier.IdentifiableItem) route.getIdentifier()).getKey();
+ final String routeKey = ribSupport.extractRouteKey(routeListKey);
+ final PathId pathId = ribSupport.extractPathId(routeListKey);
- entry.addRoute(routerId, newRoute.getPathId().getValue(), newRoute);
- this.totalPathsCounter.increment();
- } else {
- routeKey = oldRoute.getRouteKey();
- entry = this.routeEntries.get(routeKey);
- if (entry != null) {
- this.totalPathsCounter.decrement();
- if (entry.removeRoute(routerId, oldRoute.getPathId().getValue())) {
- this.routeEntries.remove(routeKey);
- this.totalPrefixesCounter.decrement();
- LOG.trace("Removed route from {}", routerId);
+ RouteEntry<C, S, R, I> entry;
+ switch (route.getModificationType()) {
+ case DELETE:
+ entry = this.routeEntries.get(routeKey);
+ if (entry != null) {
+ this.totalPathsCounter.decrement();
+ if (entry.removeRoute(routerId, pathId.getValue())) {
+ this.routeEntries.remove(routeKey);
+ this.totalPrefixesCounter.decrement();
+ LOG.trace("Removed route from {}", routerId);
+ }
}
- }
+ break;
+ case SUBTREE_MODIFIED:
+ case WRITE:
+ final R newRoute = (R) route.getDataAfter();
+ entry = this.routeEntries.get(routeKey);
+ if (entry == null) {
+ entry = createEntry(routeKey);
+ }
+
+ entry.addRoute(routerId, pathId.getValue(), newRoute);
+ this.totalPathsCounter.increment();
+ break;
+ default:
+ throw new IllegalStateException("Unhandled route modification " + route);
}
+
final RouteUpdateKey routeUpdateKey = new RouteUpdateKey(routerId, routeKey);
LOG.debug("Updated route {} entry {}", routeKey, entry);
routes.put(routeUpdateKey, entry);
default I createRouteListKey(@Nonnull final String routeKey) {
return createRouteListKey(NON_PATH_ID, routeKey);
}
+
+ /**
+ * Given a route list key, return the associated path ID.
+ *
+ * @param routeListKey Route list key
+ * @return Path ID
+ */
+ @Nonnull
+ PathId extractPathId(@Nonnull I routeListKey);
+
+ /**
+ * Given a route list key, return the associated path ID.
+ *
+ * @param routeListKey Route list key
+ * @return RouteKey
+ */
+ @Nonnull
+ String extractRouteKey(@Nonnull I routeListKey);
}
public List<Ipv4Route> routesFromContainer(final Ipv4Routes container) {
return container.getIpv4Route();
}
+
+ @Override
+ public PathId extractPathId(final Ipv4RouteKey routeListKey) {
+ return routeListKey.getPathId();
+ }
+
+ @Override
+ public String extractRouteKey(final Ipv4RouteKey routeListKey) {
+ return routeListKey.getRouteKey();
+ }
}
\ No newline at end of file