X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=bgp%2Fpath-selection-mode%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fbgp%2Fmode%2Fimpl%2Fadd%2FAddPathAbstractRouteEntry.java;h=326ff21c2bd2f4bfe4fd6651324c284a31a5871b;hb=91d98439a15e4cffca4091d10af4f4c53b4c94a6;hp=95130c7acc3b62e5f2593c029734bdbaa3e9b19f;hpb=9d0c08d6514a3e9fbf97c9cc544c478375732046;p=bgpcep.git diff --git a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java index 95130c7acc..326ff21c2b 100644 --- a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java +++ b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java @@ -22,14 +22,11 @@ import org.opendaylight.protocol.bgp.rib.spi.entry.ActualBestPathRoutes; import org.opendaylight.protocol.bgp.rib.spi.entry.AdvertizedRoute; import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryInfo; import org.opendaylight.protocol.bgp.rib.spi.entry.StaleBestPathRoute; -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.rib.Tables; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes; import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.ChoiceIn; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; @@ -45,16 +42,14 @@ import org.slf4j.LoggerFactory; * This class is NOT thread-safe. */ public abstract class AddPathAbstractRouteEntry, - S extends ChildOf, R extends Route & ChildOf & Identifiable, I extends Identifier> - implements RouteEntry { + S extends ChildOf> implements RouteEntry { private static final class Stale, - S extends ChildOf, R extends Route & ChildOf & Identifiable, - I extends Identifier> extends StaleBestPathRoute { + S extends ChildOf> extends StaleBestPathRoute { private final List addPathRouteKeyIdentifier; private final List staleRouteKeyIdentifier; private final boolean isNonAddPathBestPathNew; - Stale(final RIBSupport ribSupport, final String routeKey, final List staleRoutesPathIds, + Stale(final RIBSupport ribSupport, final String routeKey, final List staleRoutesPathIds, final List withdrawalRoutePathIds, final boolean isNonAddPathBestPathNew) { super(ribSupport.createRouteListArgument(routeKey)); this.isNonAddPathBestPathNew = isNonAddPathBestPathNew; @@ -102,8 +97,7 @@ public abstract class AddPathAbstractRouteEntry ribSup, final String routeKey, - final AddPathBestPath path) { + private MapEntryNode createRoute(final RIBSupport ribSup, final String routeKey, final AddPathBestPath path) { final RouteKeyOffsets map = this.offsets; final MapEntryNode route = map.getValue(this.values, map.offsetOf(path.getRouteKey())); return ribSup.createRoute(route, ribSup.createRouteListArgument(path.getPathIdLong(), routeKey), @@ -145,7 +139,7 @@ public abstract class AddPathAbstractRouteEntry> removeStalePaths(final RIBSupport ribSupport, + public final Optional removeStalePaths(final RIBSupport ribSupport, final String routeKey) { final List stalePaths; if (bestPathRemoved != null && !bestPathRemoved.isEmpty()) { @@ -169,18 +163,18 @@ public abstract class AddPathAbstractRouteEntry> newBestPaths(final RIBSupport ribSupport, + public final List> newBestPaths(final RIBSupport ribSupport, final String routeKey) { if (this.newBestPathToBeAdvertised == null || this.newBestPathToBeAdvertised.isEmpty()) { return List.of(); } - final List> advertized = new ArrayList<>(newBestPathToBeAdvertised.size()); + final List> advertized = new ArrayList<>(newBestPathToBeAdvertised.size()); final AddPathBestPath firstBestPath = this.bestPath.isEmpty() ? null : this.bestPath.get(0); for (final AddPathBestPath path : this.newBestPathToBeAdvertised) { final MapEntryNode routeAddPath = createRoute(ribSupport, routeKey, path); // FIXME: can we use identity check here? final boolean isFirstBestPath = firstBestPath != null && firstBestPath.equals(path); - final AdvertizedRoute adv = new AdvertizedRoute<>(ribSupport, isFirstBestPath, + final AdvertizedRoute adv = new AdvertizedRoute<>(ribSupport, isFirstBestPath, routeAddPath, path.getAttributes(), path.getPeerId(), path.isDepreferenced()); advertized.add(adv); } @@ -189,15 +183,15 @@ public abstract class AddPathAbstractRouteEntry> actualBestPaths(final RIBSupport ribSupport, + public final List> actualBestPaths(final RIBSupport ribSupport, final RouteEntryInfo entryInfo) { if (this.bestPath == null || this.bestPath.isEmpty()) { return List.of(); } - final List> preexistentRoutes = new ArrayList<>(); + final List> preexistentRoutes = new ArrayList<>(); for (final AddPathBestPath path : this.bestPath) { final MapEntryNode route = createRoute(ribSupport, entryInfo.getRouteKey(), path); - final ActualBestPathRoutes adv = new ActualBestPathRoutes<>(ribSupport, route, path.getPeerId(), + final ActualBestPathRoutes adv = new ActualBestPathRoutes<>(ribSupport, route, path.getPeerId(), path.getAttributes(), path.isDepreferenced()); preexistentRoutes.add(adv); } @@ -205,12 +199,12 @@ public abstract class AddPathAbstractRouteEntry ribSupport, final long localAs) { + public final boolean selectBest(final RIBSupport ribSupport, final long localAs) { final int size; return isBestPathNew((size = offsets.size()) == 0 ? ImmutableList.of() : selectBest(ribSupport, localAs, size)); } - protected abstract ImmutableList selectBest(RIBSupport ribSupport, long localAs, + protected abstract ImmutableList selectBest(RIBSupport ribSupport, long localAs, int size); /** @@ -219,7 +213,7 @@ public abstract class AddPathAbstractRouteEntry ribSupport, final AddPathSelector selector, + protected final void processOffset(final RIBSupport ribSupport, final AddPathSelector selector, final int offset) { final RouteKey key = offsets.getKey(offset); final MapEntryNode route = offsets.getValue(values, offset); @@ -228,7 +222,7 @@ public abstract class AddPathAbstractRouteEntry ribSupport, final int offset) { + protected final AddPathBestPath bestPathAt(final RIBSupport ribSupport, final int offset) { final MapEntryNode route = verifyNotNull(offsets.getValue(values, offset)); return new AddPathBestPath(new BestPathStateImpl(ribSupport.extractAttributes(route)), offsets.getKey(offset), offsets.getValue(pathsId, offset), offset);