2 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.rib.spi.entry;
10 import java.util.Collections;
11 import java.util.List;
12 import java.util.stream.Collectors;
13 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
18 import org.opendaylight.yangtools.yang.binding.ChildOf;
19 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
20 import org.opendaylight.yangtools.yang.binding.DataObject;
21 import org.opendaylight.yangtools.yang.binding.Identifiable;
22 import org.opendaylight.yangtools.yang.binding.Identifier;
25 * Routes to be removed from Data Store.
27 * @author Claudio D. Gasparini
29 public final class StaleBestPathRoute<C extends Routes & DataObject & ChoiceIn<Tables>,
30 S extends ChildOf<? super C>,
31 R extends Route & ChildOf<? super S> & Identifiable<I>,
32 I extends Identifier<R>> {
33 private final I nonAddPathRouteKeyIdentifier;
34 private final List<I> addPathRouteKeyIdentifier;
35 private final boolean isNonAddPathBestPathNew;
36 private final List<I> staleRouteKeyIdentifier;
38 public StaleBestPathRoute(
39 final RIBSupport<C, S, R, I> ribSupport,
40 final String routeKey,
41 final List<PathId> staleRoutesPathIds,
42 final List<PathId> withdrawalRoutePathIds,
43 final boolean isNonAddPathBestPathNew) {
44 this.isNonAddPathBestPathNew = isNonAddPathBestPathNew;
46 this.staleRouteKeyIdentifier = staleRoutesPathIds.stream()
47 .map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
48 if (withdrawalRoutePathIds != null) {
49 this.addPathRouteKeyIdentifier = withdrawalRoutePathIds.stream()
50 .map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
52 this.addPathRouteKeyIdentifier = Collections.emptyList();
54 this.nonAddPathRouteKeyIdentifier = ribSupport.createRouteListKey(routeKey);
57 public I getNonAddPathRouteKeyIdentifier() {
58 return this.nonAddPathRouteKeyIdentifier;
62 * Route Identifier List of withdrawn routes to advertize peers supporting additional Path.
64 * @return Route Identifier List
66 public List<I> getStaleRouteKeyIdentifiers() {
67 return this.staleRouteKeyIdentifier;
71 * Route Identifier List of withdrawn routes to advertize peers supporting additional Path.
73 * @return Route Identifier List
75 public List<I> getAddPathRouteKeyIdentifiers() {
76 return this.addPathRouteKeyIdentifier;
80 * Route Identifier of withdrawn routes to advertize peers no supporting additional Path.
82 * @return Route Identifier
84 public boolean isNonAddPathBestPathNew() {
85 return this.isNonAddPathBestPathNew;