*/
@NotThreadSafe
public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
- S extends ChildOf<? super C>,
- R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>>
+ S extends ChildOf<? super C>, R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>>
implements RouteEntry<C, S, R, I> {
+ private static final class Stale<C extends Routes & DataObject & ChoiceIn<Tables>,
+ S extends ChildOf<? super C>, R extends Route & ChildOf<? super S> & Identifiable<I>,
+ I extends Identifier<R>> extends StaleBestPathRoute<C, S, R, I> {
+ private final List<I> addPathRouteKeyIdentifier;
+ private final List<I> staleRouteKeyIdentifier;
+ private final boolean isNonAddPathBestPathNew;
+
+ Stale(final RIBSupport<C, S, R, I> ribSupport, final String routeKey, final List<PathId> staleRoutesPathIds,
+ final List<PathId> withdrawalRoutePathIds, final boolean isNonAddPathBestPathNew) {
+ super(ribSupport.createRouteListKey(routeKey));
+ this.isNonAddPathBestPathNew = isNonAddPathBestPathNew;
+
+ this.staleRouteKeyIdentifier = staleRoutesPathIds.stream()
+ .map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
+ if (withdrawalRoutePathIds != null) {
+ this.addPathRouteKeyIdentifier = withdrawalRoutePathIds.stream()
+ .map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
+ } else {
+ this.addPathRouteKeyIdentifier = Collections.emptyList();
+ }
+ }
+
+ @Override
+ public List<I> getStaleRouteKeyIdentifiers() {
+ return this.staleRouteKeyIdentifier;
+ }
+
+ @Override
+ public List<I> getAddPathRouteKeyIdentifiers() {
+ return addPathRouteKeyIdentifier;
+ }
+
+ @Override
+ public boolean isNonAddPathBestPathNew() {
+ return isNonAddPathBestPathNew;
+ }
+ }
private static final Logger LOG = LoggerFactory.getLogger(AddPathAbstractRouteEntry.class);
private static final Long[] EMPTY_PATHS_ID = new Long[0];
}
return stalePaths.isEmpty() && removedPaths.isEmpty() ? Optional.empty()
- : Optional.of(new StaleBestPathRoute<>(ribSupport, routeKey, stalePaths,
- removedPaths, this.isNonAddPathBestPathNew));
+ : Optional.of(new Stale<>(ribSupport, routeKey, stalePaths, removedPaths, isNonAddPathBestPathNew));
}
@Override
*/
package org.opendaylight.protocol.bgp.mode.impl.base;
-import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
-
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@NotThreadSafe
final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
- S extends ChildOf<? super C>,
- R extends Route & ChildOf<? super S> & Identifiable<I>,
- I extends Identifier<R>> implements RouteEntry<C,S,R,I> {
+ S extends ChildOf<? super C>, R extends Route & ChildOf<? super S> & Identifiable<I>,
+ I extends Identifier<R>> implements RouteEntry<C, S, R, I> {
+ private static final class Stale<C extends Routes & DataObject & ChoiceIn<Tables>,
+ S extends ChildOf<? super C>, R extends Route & ChildOf<? super S> & Identifiable<I>,
+ I extends Identifier<R>> extends StaleBestPathRoute<C, S, R, I> {
+ Stale(final I nonAddPathRouteKeyIdentifier) {
+ super(nonAddPathRouteKeyIdentifier);
+ }
+
+ @Override
+ public List<I> getStaleRouteKeyIdentifiers() {
+ return Collections.singletonList(getNonAddPathRouteKeyIdentifier());
+ }
+
+ @Override
+ public List<I> getAddPathRouteKeyIdentifiers() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public boolean isNonAddPathBestPathNew() {
+ return true;
+ }
+ }
+
private static final Logger LOG = LoggerFactory.getLogger(BaseRouteEntry.class);
private static final Route[] EMPTY_VALUES = new Route[0];
@Override
public Optional<StaleBestPathRoute<C, S, R, I>> removeStalePaths(final RIBSupport<C, S, R, I> ribSupport,
final String routeKey) {
- if (this.removedBestPath == null) {
+ if (removedBestPath == null) {
return Optional.empty();
}
- final StaleBestPathRoute<C, S, R, I> stale = new StaleBestPathRoute<>(ribSupport, routeKey,
- Collections.singletonList(NON_PATH_ID), Collections.emptyList(), true);
- this.removedBestPath = null;
- return Optional.of(stale);
+ removedBestPath = null;
+ return Optional.of(new Stale<C, S, R, I>(ribSupport.createRouteListKey(routeKey)));
}
@Override
*/
package org.opendaylight.protocol.bgp.rib.spi.entry;
-import java.util.Collections;
+import static java.util.Objects.requireNonNull;
+
import java.util.List;
-import java.util.stream.Collectors;
-import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
-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.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;
*
* @author Claudio D. Gasparini
*/
-public final class StaleBestPathRoute<C extends Routes & DataObject & ChoiceIn<Tables>,
- S extends ChildOf<? super C>,
- R extends Route & ChildOf<? super S> & Identifiable<I>,
- I extends Identifier<R>> {
+public abstract class StaleBestPathRoute<C extends Routes & DataObject & ChoiceIn<Tables>,
+ S extends ChildOf<? super C>, R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>> {
private final I nonAddPathRouteKeyIdentifier;
- private final List<I> addPathRouteKeyIdentifier;
- private final boolean isNonAddPathBestPathNew;
- private final List<I> staleRouteKeyIdentifier;
-
- public StaleBestPathRoute(
- final RIBSupport<C, S, R, I> ribSupport,
- final String routeKey,
- final List<PathId> staleRoutesPathIds,
- final List<PathId> withdrawalRoutePathIds,
- final boolean isNonAddPathBestPathNew) {
- this.isNonAddPathBestPathNew = isNonAddPathBestPathNew;
- this.staleRouteKeyIdentifier = staleRoutesPathIds.stream()
- .map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
- if (withdrawalRoutePathIds != null) {
- this.addPathRouteKeyIdentifier = withdrawalRoutePathIds.stream()
- .map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
- } else {
- this.addPathRouteKeyIdentifier = Collections.emptyList();
- }
- this.nonAddPathRouteKeyIdentifier = ribSupport.createRouteListKey(routeKey);
+ protected StaleBestPathRoute(final I nonAddPathRouteKeyIdentifier) {
+ this.nonAddPathRouteKeyIdentifier = requireNonNull(nonAddPathRouteKeyIdentifier);
}
- public I getNonAddPathRouteKeyIdentifier() {
- return this.nonAddPathRouteKeyIdentifier;
+ public final I getNonAddPathRouteKeyIdentifier() {
+ return nonAddPathRouteKeyIdentifier;
}
/**
*
* @return Route Identifier List
*/
- public List<I> getStaleRouteKeyIdentifiers() {
- return this.staleRouteKeyIdentifier;
- }
+ public abstract List<I> getStaleRouteKeyIdentifiers();
/**
* Route Identifier List of withdrawn routes to advertize peers supporting additional Path.
*
* @return Route Identifier List
*/
- public List<I> getAddPathRouteKeyIdentifiers() {
- return this.addPathRouteKeyIdentifier;
- }
+ public abstract List<I> getAddPathRouteKeyIdentifiers();
/**
* Route Identifier of withdrawn routes to advertize peers no supporting additional Path.
*
* @return Route Identifier
*/
- public boolean isNonAddPathBestPathNew() {
- return this.isNonAddPathBestPathNew;
- }
+ public abstract boolean isNonAddPathBestPathNew();
}