}
@Override
- public EvpnRoute createRoute(final EvpnRoute route, final String routeKey, final long pathId,
- final Attributes attributes) {
+ public EvpnRoute createRoute(final EvpnRoute route, final EvpnRouteKey key, final Attributes attributes) {
final EvpnRouteBuilder builder;
if (route != null) {
builder = new EvpnRouteBuilder(route);
} else {
builder = new EvpnRouteBuilder();
}
- return builder.withKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
}
@Override
- public EvpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new EvpnRouteKey(new PathId(pathId), routeKey);
+ public EvpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new EvpnRouteKey(pathId, routeKey);
}
@Override
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
- ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
}
@Override
- public FlowspecRoute createRoute(final FlowspecRoute route, final String routeKey, final long pathId,
+ public FlowspecRoute createRoute(final FlowspecRoute route, final FlowspecRouteKey key,
final Attributes attributes) {
final FlowspecRouteBuilder builder;
if (route != null) {
} else {
builder = new FlowspecRouteBuilder();
}
- return builder.withKey(new FlowspecRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
}
@Override
- public FlowspecRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new FlowspecRouteKey(new PathId(pathId), routeKey);
+ public FlowspecRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new FlowspecRouteKey(pathId, routeKey);
}
@Override
}
@Override
- public FlowspecRoute createRoute(final FlowspecRoute route, final String routeKey,
- final long pathId, final Attributes attributes) {
+ public FlowspecRoute createRoute(final FlowspecRoute route, final FlowspecRouteKey key,
+ final Attributes attributes) {
final FlowspecRouteBuilder builder;
if (route != null) {
builder = new FlowspecRouteBuilder(route);
} else {
builder = new FlowspecRouteBuilder();
}
- return builder.withKey(new FlowspecRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
}
@Override
- public FlowspecRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new FlowspecRouteKey(new PathId(pathId), routeKey);
+ public FlowspecRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new FlowspecRouteKey(pathId, routeKey);
}
@Override
}
@Override
- public FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
+ public FlowspecL3vpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new FlowspecL3vpnRouteKey(pathId, routeKey);
}
@Override
- public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final String routeKey,
- final long pathId, final Attributes attributes) {
+ public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final FlowspecL3vpnRouteKey key,
+ final Attributes attributes) {
final FlowspecL3vpnRouteBuilder builder;
if (route != null) {
builder = new FlowspecL3vpnRouteBuilder(route);
} else {
builder = new FlowspecL3vpnRouteBuilder();
}
- return builder.withKey(new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey))
- .setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
}
@Override
- public FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
+ public FlowspecL3vpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new FlowspecL3vpnRouteKey(pathId, routeKey);
}
@Override
- public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final String routeKey,
- final long pathId, final Attributes attributes) {
+ public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final FlowspecL3vpnRouteKey key,
+ final Attributes attributes) {
final FlowspecL3vpnRouteBuilder builder;
if (route != null) {
builder = new FlowspecL3vpnRouteBuilder(route);
} else {
builder = new FlowspecL3vpnRouteBuilder();
}
- return builder.withKey(new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey))
- .setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
@Test
public void testRouteIdAddPath() {
- assertEquals(this.routeKey, this.ribSupport.createRouteListKey(1L, this.routeKey.getRouteKey()));
+ assertEquals(this.routeKey, this.ribSupport.createRouteListKey(routeKey.getPathId(), routeKey.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- assertEquals(this.routeKey, this.ribSupport.createRouteListKey(1L, this.routeKey.getRouteKey()));
+ assertEquals(this.routeKey, this.ribSupport.createRouteListKey(routeKey.getPathId(), routeKey.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(),
+ ROUTE_KEY.getRouteKey()));
}
@Test
}
@Override
- public Ipv4Route createRoute(final Ipv4Route route, final String routeKey, final long pathId,
- final Attributes attributes) {
+ public Ipv4Route createRoute(final Ipv4Route route, final Ipv4RouteKey key, final Attributes attributes) {
final Ipv4RouteBuilder builder;
if (route != null) {
builder = new Ipv4RouteBuilder(route);
} else {
builder = new Ipv4RouteBuilder();
}
- builder.withKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes);
+ builder.withKey(key).setAttributes(attributes);
return builder.build();
}
}
@Override
- public Ipv4RouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new Ipv4RouteKey(new PathId(pathId), routeKey);
+ public Ipv4RouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new Ipv4RouteKey(pathId, routeKey);
}
@Override
}
@Override
- public Ipv6Route createRoute(final Ipv6Route route, final String routeKey, final long pathId,
- final Attributes attributes) {
+ public Ipv6Route createRoute(final Ipv6Route route, final Ipv6RouteKey key, final Attributes attributes) {
final Ipv6RouteBuilder builder;
if (route != null) {
builder = new Ipv6RouteBuilder(route);
} else {
builder = new Ipv6RouteBuilder();
}
- return builder.withKey(new Ipv6RouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
}
@Override
- public Ipv6RouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new Ipv6RouteKey(new PathId(pathId), routeKey);
+ public Ipv6RouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new Ipv6RouteKey(pathId, routeKey);
}
@Override
@Test
public void testRouteIdAddPath() {
final Ipv4RouteKey expected = new Ipv4RouteKey(new PathId(1L), PREFIX.getValue());
- assertEquals(expected, this.ribSupport.createRouteListKey(expected.getPathId().getValue(), PREFIX.getValue()));
+ assertEquals(expected, this.ribSupport.createRouteListKey(expected.getPathId(), PREFIX.getValue()));
}
@Test
@Test
public void testRouteIdAddPath() {
final Ipv6RouteKey expected = new Ipv6RouteKey(new PathId(1L), PREFIX.getValue());
- assertEquals(expected, this.ribSupport.createRouteListKey(expected.getPathId().getValue(), PREFIX.getValue()));
+ assertEquals(expected, this.ribSupport.createRouteListKey(expected.getPathId(), PREFIX.getValue()));
}
@Test
protected abstract IpPrefix createPrefix(String prefix);
@Override
- public final L3vpnMcastRoute createRoute(final L3vpnMcastRoute route, final String routeKey, final long pathId,
+ public final L3vpnMcastRoute createRoute(final L3vpnMcastRoute route, final L3vpnMcastRouteKey key,
final Attributes attributes) {
final L3vpnMcastRouteBuilder builder;
if (route != null) {
} else {
builder = new L3vpnMcastRouteBuilder();
}
- return builder.withKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
- public final L3vpnMcastRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new L3vpnMcastRouteKey(new PathId(pathId), routeKey);
+ public final L3vpnMcastRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new L3vpnMcastRouteKey(pathId, routeKey);
}
@Override
}
@Override
- public final VpnRoute createRoute(final VpnRoute route, final String vpnRouteKey,
- final long pathId, final Attributes attributes) {
+ public final VpnRoute createRoute(final VpnRoute route, final VpnRouteKey key, final Attributes attributes) {
final VpnRouteBuilder builder;
if (route != null) {
builder = new VpnRouteBuilder(route);
} else {
builder = new VpnRouteBuilder();
}
- return builder.withKey(new VpnRouteKey(new PathId(pathId), vpnRouteKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
- public final VpnRouteKey createRouteListKey(final long pathId, final String vpnRouteKey) {
- return new VpnRouteKey(new PathId(pathId), vpnRouteKey);
+ public VpnRouteKey createRouteListKey(final PathId pathId, final String vpnRouteKey) {
+ return new VpnRouteKey(pathId, vpnRouteKey);
}
@Override
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
- ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(),
+ ROUTE_KEY.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(),
ROUTE_KEY.getRouteKey()));
}
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(0L, ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(),
+ ROUTE_KEY.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(0L, ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(),
+ ROUTE_KEY.getRouteKey()));
}
@Test
}
@Override
- public final LabeledUnicastRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new LabeledUnicastRouteKey(new PathId(pathId), routeKey);
+ public final LabeledUnicastRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new LabeledUnicastRouteKey(pathId, routeKey);
}
@Override
- public final LabeledUnicastRoute createRoute(final LabeledUnicastRoute route, final String routeKey,
- final long pathId, final Attributes attributes) {
+ public final LabeledUnicastRoute createRoute(final LabeledUnicastRoute route, final LabeledUnicastRouteKey key,
+ final Attributes attributes) {
final LabeledUnicastRouteBuilder builder;
if (route != null) {
builder = new LabeledUnicastRouteBuilder(route);
} else {
builder = new LabeledUnicastRouteBuilder();
}
- return builder.withKey(new LabeledUnicastRouteKey(new PathId(pathId), routeKey))
- .setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
}
@Override
- public LinkstateRoute createRoute(final LinkstateRoute route, final String routeKey,
- final long pathId, final Attributes attributes) {
+ public LinkstateRoute createRoute(final LinkstateRoute route, final LinkstateRouteKey key,
+ final Attributes attributes) {
final LinkstateRouteBuilder builder;
if (route != null) {
builder = new LinkstateRouteBuilder(route);
} else {
builder = new LinkstateRouteBuilder();
}
- return builder.withKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
}
@Override
- public LinkstateRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new LinkstateRouteKey(new PathId(pathId), routeKey);
+ public LinkstateRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new LinkstateRouteKey(pathId, routeKey);
}
@Override
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.math.BigInteger;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.junit.Assert;
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(),
ROUTE_KEY.getRouteKey()));
}
}
@Override
- public final MvpnRoute createRoute(final MvpnRoute route, final String routeKey, final long pathId,
- final Attributes attributes) {
+ public final MvpnRoute createRoute(final MvpnRoute route, final MvpnRouteKey key, final Attributes attributes) {
final MvpnRouteBuilder builder;
if (route != null) {
builder = new MvpnRouteBuilder(route);
} else {
builder = new MvpnRouteBuilder();
}
- return builder.withKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
@Override
- public final MvpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new MvpnRouteKey(new PathId(pathId), routeKey);
+ public final MvpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new MvpnRouteKey(pathId, routeKey);
}
@Override
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
- ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
- ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
}
@Override
- public RouteTargetConstrainRoute createRoute(
- final RouteTargetConstrainRoute route,
- final String routeKey,
- final long pathId,
- final Attributes attributes) {
+ public RouteTargetConstrainRoute createRoute(final RouteTargetConstrainRoute route,
+ final RouteTargetConstrainRouteKey key, final Attributes attributes) {
final RouteTargetConstrainRouteBuilder builder;
if (route != null) {
builder = new RouteTargetConstrainRouteBuilder(route);
} else {
builder = new RouteTargetConstrainRouteBuilder();
}
- return builder.withKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ return builder.withKey(key).setAttributes(attributes).build();
}
-
@Override
public RouteTargetConstrainRoutesCase emptyRoutesCase() {
return EMPTY_CASE;
return EMPTY_CONTAINER;
}
-
@Override
- public RouteTargetConstrainRouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new RouteTargetConstrainRouteKey(new PathId(pathId), routeKey);
+ public RouteTargetConstrainRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new RouteTargetConstrainRouteKey(pathId, routeKey);
}
@Override
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
- ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId(), ROUTE_KEY.getRouteKey()));
}
@Test
*/
package org.opendaylight.protocol.bgp.mode.impl.add;
+import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
+import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.primitives.UnsignedInteger;
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.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;
private List<AddPathBestPath> newBestPathToBeAdvertised;
private List<Long> removedPathsId;
- private R createRoute(final RIBSupport<C, S, R, I> ribSup, final String routeKey,
- final long pathId, final AddPathBestPath path) {
+ private R createRoute(final RIBSupport<C, S, R, I> ribSup, final String routeKey, final AddPathBestPath path) {
final OffsetMap map = getOffsets();
final R route = map.getValue(this.values, map.offsetOf(path.getRouteKey()));
- return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
+ return ribSup.createRoute(route, ribSup.createRouteListKey(pathIdObj(path.getPathId()), routeKey),
+ path.getAttributes());
}
@Override
final List<AdvertizedRoute<C, S, R, I>> advertized = new ArrayList<>(newBestPathToBeAdvertised.size());
final AddPathBestPath firstBestPath = this.bestPath.isEmpty() ? null : this.bestPath.get(0);
for (final AddPathBestPath path : this.newBestPathToBeAdvertised) {
- final R routeAddPath = createRoute(ribSupport, routeKey, path.getPathId(), path);
+ final R routeAddPath = createRoute(ribSupport, routeKey, path);
// FIXME: can we use identity check here?
final boolean isFirstBestPath = firstBestPath != null && firstBestPath.equals(path);
final AdvertizedRoute<C, S, R, I> adv = new AdvertizedRoute<>(ribSupport, isFirstBestPath,
}
final List<ActualBestPathRoutes<C, S, R, I>> preexistentRoutes = new ArrayList<>();
for (final AddPathBestPath path : this.bestPath) {
- final R route = createRoute(ribSupport, entryInfo.getRouteKey(), path.getPathId(), path);
+ final R route = createRoute(ribSupport, entryInfo.getRouteKey(), path);
final ActualBestPathRoutes<C, S, R, I> adv = new ActualBestPathRoutes<>(ribSupport, route, path.getPeerId(),
path.getAttributes(), path.isDepreferenced());
preexistentRoutes.add(adv);
present.ifPresent(addPathBestPath -> this.bestPathRemoved.remove(oldBest));
});
}
+
+ private static PathId pathIdObj(final long pathId) {
+ return pathId == NON_PATH_ID_VALUE ? NON_PATH_ID : new PathId(pathId);
+ }
}
package org.opendaylight.protocol.bgp.mode.impl.base;
import static java.util.Objects.requireNonNull;
+import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.primitives.UnsignedInteger;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
final class BaseBestPath extends AbstractBestPath {
- private static final short PATH_ID = 0;
private final UnsignedInteger routerId;
BaseBestPath(@Nonnull final UnsignedInteger routerId, @Nonnull final BestPathState state) {
@Override
public long getPathId() {
- return PATH_ID;
+ return NON_PATH_ID_VALUE;
}
@Override
return this.offsets.isEmpty();
}
- private R createRoute(final RIBSupport<C, S, R, I> ribSup, final String routeKey, final long pathId,
- final BaseBestPath path) {
- final R route = this.offsets.getValue(this.values, this.offsets.offsetOf(path.getRouterId()));
- return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
+ private R createRoute(final RIBSupport<C, S, R, I> ribSup, final String routeKey) {
+ final I key = ribSup.createRouteListKey(routeKey);
+ final R route = this.offsets.getValue(this.values, this.offsets.offsetOf(bestPath.getRouterId()));
+ return ribSup.createRoute(route, key, bestPath.getAttributes());
}
@Override
if (this.bestPath == null) {
return Collections.emptyList();
}
- final R route = createRoute(ribSupport, routeKey, this.bestPath.getPathId(), this.bestPath);
+ final R route = createRoute(ribSupport, routeKey);
final AdvertizedRoute<C, S, R, I> adv = new AdvertizedRoute<>(ribSupport, route, this.bestPath.getAttributes(),
this.bestPath.getPeerId(), this.bestPath.isDepreferenced());
LOG.trace("Selected best route {}", route);
if (this.bestPath == null) {
return Collections.emptyList();
}
- final R route = createRoute(ribSupport, entryInfo.getRouteKey(), this.bestPath.getPathId(), this.bestPath);
+ final R route = createRoute(ribSupport, entryInfo.getRouteKey());
return Collections.singletonList(new ActualBestPathRoutes<>(ribSupport, route, this.bestPath.getPeerId(),
this.bestPath.getAttributes(), this.bestPath.isDepreferenced()));
}
*/
package org.opendaylight.protocol.bgp.rib.impl;
-import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
-
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
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.RouteKeyIdentifier;
import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryDependenciesContainer;
+import org.opendaylight.protocol.bgp.rib.spi.entry.RouteKeyIdentifier;
import org.opendaylight.protocol.bgp.rib.spi.entry.StaleBestPathRoute;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
R extends Route & ChildOf<? super S> & Identifiable<I>,
I extends Identifier<R>> void initializeRibOut(
final RouteEntryDependenciesContainer entryDep,
- List<ActualBestPathRoutes<C, S, R, I>> routesToStore) {
+ final List<ActualBestPathRoutes<C, S, R, I>> routesToStore) {
if (this.bindingChain == null) {
LOG.debug("Session closed, skip changes to peer AdjRibsOut {}", getPeerId());
return;
public final synchronized <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
R extends Route & ChildOf<? super S> & Identifiable<I>,
I extends Identifier<R>> void refreshRibOut(final RouteEntryDependenciesContainer entryDep,
- final List<StaleBestPathRoute<C, S, R, I>> staleRoutes, List<AdvertizedRoute<C, S, R, I>> newRoutes) {
+ final List<StaleBestPathRoute<C, S, R, I>> staleRoutes, final List<AdvertizedRoute<C, S, R, I>> newRoutes) {
if (this.bindingChain == null) {
LOG.debug("Session closed, skip changes to peer AdjRibsOut {}", getPeerId());
return;
}, MoreExecutors.directExecutor());
}
+ @Override
public final synchronized <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
R extends Route & ChildOf<? super S> & Identifiable<I>,
I extends Identifier<R>> void reEvaluateAdvertizement(
final RouteEntryDependenciesContainer entryDep,
- List<ActualBestPathRoutes<C, S, R, I>> routesToStore) {
+ final List<ActualBestPathRoutes<C, S, R, I>> routesToStore) {
if (this.bindingChain == null) {
LOG.debug("Session closed, skip changes to peer AdjRibsOut {}", getPeerId());
return;
for (final AdvertizedRoute<C,S,R,I> advRoute:routes) {
final PeerId fromPeerId = advRoute.getFromPeerId();
- if (!filterRoutes(fromPeerId, tk) || (!advRoute.isFirstBestPath() && !addPathSupported)) {
+ if (!filterRoutes(fromPeerId, tk) || !advRoute.isFirstBestPath() && !addPathSupported) {
continue;
}
final R route = advRoute.getRoute();
final RouteKeyIdentifier<R, I> advRoute, final R route, final Attributes effAttr,
final WriteTransaction tx) {
final InstanceIdentifier<R> ribOut;
- final R newRoute;
+ final I newKey;
if (!addPathSupported) {
ribOut = ribSupport.createRouteIdentifier(tableRibout, advRoute.getNonAddPathRouteKeyIdentifier());
- newRoute = ribSupport.createRoute(route, route.getRouteKey(), NON_PATH_ID_VALUE, effAttr);
+ newKey = ribSupport.createRouteListKey(route.getRouteKey());
} else {
ribOut = ribSupport.createRouteIdentifier(tableRibout, advRoute.getAddPathRouteKeyIdentifier());
- newRoute = ribSupport.createRoute(route, route.getRouteKey(), route.getPathId().getValue(), effAttr);
+ newKey = ribSupport.createRouteListKey(route.getPathId(), route.getRouteKey());
}
+ final R newRoute = ribSupport.createRoute(route, newKey, effAttr);
LOG.debug("Write advRoute {} to peer AdjRibsOut {}", advRoute, getPeerId());
tx.put(LogicalDatastoreType.OPERATIONAL, ribOut, newRoute);
}
private final Set<TablesKey> gracefulAfiSafiAdvertised = new HashSet<>();
private RIBImpl ribImpl;
private Channel serverChannel;
- private SimpleSessionListener listener = new SimpleSessionListener();
+ private final SimpleSessionListener listener = new SimpleSessionListener();
private final BgpParameters parameters = createParameter(false, true, Collections.singletonMap(TABLES_KEY, true));
private static final int DEFERRAL_TIMER = 5;
private static final RibId RIBID = new RibId("test-rib");
this.session = createPeerSession(PEER1, parameters, this.listener);
}
+ @Override
@After
public void tearDown() throws ExecutionException, InterruptedException {
waitFutureSuccess(this.serverChannel.close());
});
}
- private void insertRoutes(List<Ipv4Prefix> ipv4prefixes, List<Ipv6Prefix> ipv6prefixes) {
+ private void insertRoutes(final List<Ipv4Prefix> ipv4prefixes, final List<Ipv6Prefix> ipv6prefixes) {
insertRoutes(ipv4prefixes, PEER1, ipv6prefixes, IPV6_NEXT_HOP, this.session, BgpOrigin.Igp);
}
- private void insertRoutes(final List<Ipv4Prefix> ipv4prefixes, final Ipv4Address ipv4NeighborAddress,
+ private static void insertRoutes(final List<Ipv4Prefix> ipv4prefixes, final Ipv4Address ipv4NeighborAddress,
final List<Ipv6Prefix> ipv6prefixes, final Ipv6Address ipv6NeighborAddress,
final BGPSessionImpl session, final BgpOrigin peerRole) {
if (ipv4prefixes == null && ipv6prefixes == null) {
}
if (ipv4prefixes != null && !ipv4prefixes.isEmpty()) {
- final MpReachNlri reachIpv4 = PeerUtil.createMpReachNlri(new IpAddress(ipv4NeighborAddress), 0,
+ final MpReachNlri reachIpv4 = PeerUtil.createMpReachNlri(new IpAddress(ipv4NeighborAddress),
ipv4prefixes.stream()
.map(IpPrefix::new)
.collect(Collectors.toList()));
}
if (ipv6prefixes != null && !ipv4prefixes.isEmpty()) {
- final MpReachNlri reachIpv6 = PeerUtil.createMpReachNlri(new IpAddress(ipv6NeighborAddress), 0,
+ final MpReachNlri reachIpv6 = PeerUtil.createMpReachNlri(new IpAddress(ipv6NeighborAddress),
ipv6prefixes.stream()
.map(IpPrefix::new)
.collect(Collectors.toList()));
}
}
- private static Open createClassicOpen(boolean addGraceful) {
+ private static Open createClassicOpen(final boolean addGraceful) {
final Map<TablesKey, Boolean> graceful = new HashMap<>();
if (addGraceful) {
graceful.put(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class), true);
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.destination.ipv6.Ipv6PrefixesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6CaseBuilder;
-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.message.rev180329.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.UpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters;
throw new UnsupportedOperationException();
}
- static MpReachNlri createMpReachNlri(final IpAddress nextHop, final long pathId, final List<IpPrefix> prefixes) {
+ static MpReachNlri createMpReachNlri(final IpAddress nextHop, final List<IpPrefix> prefixes) {
final Class<? extends AddressFamily> afi;
final CNextHop cNextHop;
final DestinationType destinationType;
destinationType = new DestinationIpv4CaseBuilder().setDestinationIpv4(
new DestinationIpv4Builder().setIpv4Prefixes(prefixes.stream()
.map(prefix -> new Ipv4PrefixesBuilder()
- .setPathId(new PathId(pathId))
+ .setPathId(PathIdUtil.NON_PATH_ID)
.setPrefix(new Ipv4Prefix(prefix.getIpv4Prefix())).build())
.collect(Collectors.toList()))
.build()).build();
destinationType = new DestinationIpv6CaseBuilder().setDestinationIpv6(
new DestinationIpv6Builder().setIpv6Prefixes(prefixes.stream()
.map(prefix -> new Ipv6PrefixesBuilder()
- .setPathId(new PathId(pathId))
+ .setPathId(PathIdUtil.NON_PATH_ID)
.setPrefix(new Ipv6Prefix(prefix.getIpv6Prefix())).build())
.collect(Collectors.toList()))
.build()).build();
*/
package org.opendaylight.protocol.bgp.rib.spi;
-import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
+import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+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.message.rev180329.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
* Creates a route with new path Id and attributes.
*
* @param route route
- * @param routeKey route key
- * @param pathId new path Id
+ * @param key route key
* @param attributes route attributes
* @return Route List key
*/
@Nonnull
- R createRoute(@Nullable R route, String routeKey, @Nullable long pathId, @Nonnull Attributes attributes);
+ R createRoute(@Nullable R route, @Nonnull I key, @Nonnull Attributes attributes);
/**
* Returns TablesKey which we are providing support.
* @return route list Key (RouteKey + pathId)
*/
@Nonnull
- I createRouteListKey(@Nonnull long pathId, @Nonnull String routeKey);
+ I createRouteListKey(@Nonnull PathId pathId, @Nonnull String routeKey);
/**
- * Construct a Route List Key using new path Id for Families.
+ * Construct a Route List Key.
*
* @param routeKey RouteKey
* @return route list Key (RouteKey + empty pathId)
*/
@Nonnull
default I createRouteListKey(@Nonnull final String routeKey) {
- return createRouteListKey(NON_PATH_ID_VALUE, routeKey);
+ return createRouteListKey(NON_PATH_ID, routeKey);
}
}
final @NonNull String routeKey = verifyNotNull(route.getRouteKey());
this.nonAddPathRouteKeyIdentifier = ribSupport.createRouteListKey(routeKey);
- this.addPathRouteKeyIdentifier = ribSupport.createRouteListKey(route.getPathId().getValue(), routeKey);
+ // FIXME: can we just use route.key()?
+ this.addPathRouteKeyIdentifier = ribSupport.createRouteListKey(route.getPathId(), routeKey);
}
public final PeerId getFromPeerId() {
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
+import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
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;
final boolean isNonAddPathBestPathNew) {
this.isNonAddPathBestPathNew = isNonAddPathBestPathNew;
- this.staleRouteKeyIdentifier = staleRoutesPathIds.stream()
+ this.staleRouteKeyIdentifier = staleRoutesPathIds.stream().map(StaleBestPathRoute::pathIdObj)
.map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
if (withdrawalRoutePathIds != null) {
- this.addPathRouteKeyIdentifier = withdrawalRoutePathIds.stream()
+ this.addPathRouteKeyIdentifier = withdrawalRoutePathIds.stream().map(StaleBestPathRoute::pathIdObj)
.map(pathId -> ribSupport.createRouteListKey(pathId, routeKey)).collect(Collectors.toList());
} else {
this.addPathRouteKeyIdentifier = Collections.emptyList();
public boolean isNonAddPathBestPathNew() {
return this.isNonAddPathBestPathNew;
}
+
+ private static PathId pathIdObj(final Long pathId) {
+ return pathId == NON_PATH_ID_VALUE ? PathIdUtil.NON_PATH_ID : new PathId(pathId);
+ }
}
}
@Override
- public Ipv4Route createRoute(final Ipv4Route route, final String routeKey, final long pathId,
- final Attributes attributes) {
+ public Ipv4Route createRoute(final Ipv4Route route, final Ipv4RouteKey key, final Attributes attributes) {
return null;
}
}
@Override
- public Ipv4RouteKey createRouteListKey(final long pathId, final String routeKey) {
- return new Ipv4RouteKey(new PathId(pathId), routeKey);
+ public Ipv4RouteKey createRouteListKey(final PathId pathId, final String routeKey) {
+ return new Ipv4RouteKey(pathId, routeKey);
}
@Override