Centralize PathId allocation 24/78524/15
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Dec 2018 19:26:03 +0000 (20:26 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 10 Dec 2018 14:43:44 +0000 (14:43 +0000)
Using long for pathId selection is highly inefficient, as it forces
each AFI/SAFI to deal with it separately. Concenrate allocation in
a single place, so we can actually have a proper interface.

Change-Id: I515d7f0c6fce80b45561939999322f273e8a4197
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
40 files changed:
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java
bgp/extensions/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupportTest.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv4RIBSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv6RIBSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv4/FlowspecL3vpnIpv4RIBSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6RIBSupport.java
bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv4RIBSupportTest.java
bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv6RIBSupportTest.java
bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv4RIBSupportTest.java
bgp/extensions/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv6RIBSupportTest.java
bgp/extensions/inet/src/main/java/org/opendaylight/protocol/bgp/inet/IPv4RIBSupport.java
bgp/extensions/inet/src/main/java/org/opendaylight/protocol/bgp/inet/IPv6RIBSupport.java
bgp/extensions/inet/src/test/java/org/opendaylight/protocol/bgp/inet/IPv4RIBSupportTest.java
bgp/extensions/inet/src/test/java/org/opendaylight/protocol/bgp/inet/IPv6RIBSupportTest.java
bgp/extensions/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/AbstractL3vpnMcastIpRIBSupport.java
bgp/extensions/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/AbstractVpnRIBSupport.java
bgp/extensions/l3vpn/src/test/java/org/opendaylight/protocol/bgp/l3vpn/mcast/L3vpnMcastIpv4RIBSupportTest.java
bgp/extensions/l3vpn/src/test/java/org/opendaylight/protocol/bgp/l3vpn/mcast/L3vpnMcastIpv6RIBSupportTest.java
bgp/extensions/l3vpn/src/test/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv4/VpnIpv4RIBSupportTest.java
bgp/extensions/l3vpn/src/test/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv6/VpnIpv6RIBSupportTest.java
bgp/extensions/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/AbstractLabeledUnicastRIBSupport.java
bgp/extensions/labeled-unicast/src/test/java/org/opendaylight/protocol/bgp/labeled/unicast/LabeledUnicastIpv4RIBSupportTest.java
bgp/extensions/labeled-unicast/src/test/java/org/opendaylight/protocol/bgp/labeled/unicast/LabeledUnicastIpv6RIBSupportTest.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/LinkstateRIBSupport.java
bgp/extensions/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/LinkstateRIBSupportTest.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/AbstractMvpnRIBSupport.java
bgp/extensions/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/MvpnIpv4RIBSupportTest.java
bgp/extensions/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/MvpnIpv6RIBSupportTest.java
bgp/extensions/route-target/src/main/java/org/opendaylight/protocol/bgp/route/targetcontrain/impl/RouteTargetConstrainRIBSupport.java
bgp/extensions/route-target/src/test/java/org/opendaylight/protocol/bgp/route/targetcontrain/impl/RouteTargetConstrainRIBSupportTest.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseBestPath.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseRouteEntry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractPeer.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/GracefulRestartTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerUtil.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/AbstractAdvertizedRoute.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/StaleBestPathRoute.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupportTestImp.java

index eb6ce80b77ab6f6e2d4be157f80527608111490b..0a9ee6001a3daa83bb9f132154d9b1b0697ccf49 100644 (file)
@@ -135,15 +135,14 @@ final class EvpnRibSupport extends AbstractRIBSupport<EvpnRoutesCase, EvpnRoutes
     }
 
     @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
@@ -157,8 +156,8 @@ final class EvpnRibSupport extends AbstractRIBSupport<EvpnRoutesCase, EvpnRoutes
     }
 
     @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
index 3667d5b6ecea6b74b96c0cd025674145ad364789..1cd4e725484933fc5ba0b784838083f99c20c8e1 100644 (file)
@@ -147,8 +147,7 @@ public final class EvpnRibSupportTest extends AbstractRIBSupportTest<EvpnRoutesC
 
     @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
index d5a8014cbdab31fa4f0d990a87643d7378367db5..53fefc55365c5ff49a239ed66e642c5791b9a19d 100644 (file)
@@ -61,7 +61,7 @@ public final class FlowspecIpv4RIBSupport
     }
 
     @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) {
@@ -69,7 +69,7 @@ public final class FlowspecIpv4RIBSupport
         } else {
             builder = new FlowspecRouteBuilder();
         }
-        return builder.withKey(new FlowspecRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
+        return builder.withKey(key).setAttributes(attributes).build();
     }
 
     @Override
@@ -83,8 +83,8 @@ public final class FlowspecIpv4RIBSupport
     }
 
     @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
index 9fd1c5011391c00200c643282131aa892d855f1c..820bbfbf089552869b09fadabb6a7a4d1f1cd7af 100644 (file)
@@ -61,15 +61,15 @@ public final class FlowspecIpv6RIBSupport
     }
 
     @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
@@ -83,8 +83,8 @@ public final class FlowspecIpv6RIBSupport
     }
 
     @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
index 561a050cd09c6c9d884e71f8131bc13e93a55e3a..b46e3986d1a3d4a79cd096743da22d2ad330ad9b 100644 (file)
@@ -62,21 +62,20 @@ public final class FlowspecL3vpnIpv4RIBSupport
     }
 
     @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
index 1114a7cd5ad563f3a86a38c9c35ed822b570f47b..7b7798018c9bc31fec4945991faeb7fca4303545 100644 (file)
@@ -62,21 +62,20 @@ public final class FlowspecL3vpnIpv6RIBSupport
     }
 
     @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
index c46c4584160db31b6f6374afd7d4036771ef7ce8..6ebd913d88d64405851897fbc9c0af1866997ace 100644 (file)
@@ -140,7 +140,7 @@ public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecR
 
     @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
index 4354c6bcc639c367139ae25f31564051036fcbfb..318249ddb23a66236d7f2ad627b88ab62e64064e 100644 (file)
@@ -140,7 +140,7 @@ public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecI
 
     @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
index 66dde7a38a95b768df6abe151304a9b252408f26..9cde610bd69f446586c0c35272e820f426ec3cc7 100644 (file)
@@ -137,7 +137,7 @@ public class FlowspecL3vpnIpv4RIBSupportTest extends AbstractRIBSupportTest<Flow
 
     @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
index d950139932fa218a75ee531bc5d25c45517335d5..38432bb928481ba7fb1512b8f24ed94590e0acf9 100644 (file)
@@ -140,7 +140,8 @@ public class FlowspecL3vpnIpv6RIBSupportTest extends AbstractRIBSupportTest<Flow
 
     @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
index 00426892fb8bd0872c65e996803bfeee314a585a..d680be77beb5cee4cbb7c168cad7259c256e3adb 100644 (file)
@@ -89,15 +89,14 @@ final class IPv4RIBSupport extends AbstractIPRibSupport<Ipv4RoutesCase, Ipv4Rout
     }
 
     @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();
     }
 
@@ -112,8 +111,8 @@ final class IPv4RIBSupport extends AbstractIPRibSupport<Ipv4RoutesCase, Ipv4Rout
     }
 
     @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
index acc8d56a9a4c7faf9df178a2a790a985ae424d69..037432069ad4369f689017fbefb7cb54cb748276 100644 (file)
@@ -86,15 +86,14 @@ final class IPv6RIBSupport extends AbstractIPRibSupport<Ipv6RoutesCase, Ipv6Rout
     }
 
     @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
@@ -108,8 +107,8 @@ final class IPv6RIBSupport extends AbstractIPRibSupport<Ipv6RoutesCase, Ipv6Rout
     }
 
     @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
index ac5e9ebb9939ed995bba684a4e1f9a5ec10594bb..d2f99aca81ce910b38b374a680cf8c9ce10d500d 100644 (file)
@@ -129,7 +129,7 @@ public final class IPv4RIBSupportTest extends AbstractRIBSupportTest<Ipv4RoutesC
     @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
index 7aad3e330b0d78aa51ceb38029c9f3f664bc51ff..322bef429780b2bede7ab3d4a161c4160b8bb7f6 100644 (file)
@@ -130,7 +130,7 @@ public final class IPv6RIBSupportTest extends AbstractRIBSupportTest<Ipv6RoutesC
     @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
index 50587d24d912b06d3050683ebd7157b86200835a..8c2635f7ce640bafd5a509d30060d325ad262cd8 100644 (file)
@@ -102,7 +102,7 @@ abstract class AbstractL3vpnMcastIpRIBSupport<
     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) {
@@ -110,12 +110,12 @@ abstract class AbstractL3vpnMcastIpRIBSupport<
         } 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
index 1ffa2395a856da09f7b12a59bb6f39fdc0739fbd..111660fa9d79eb615d1ad70f55aecbdfacd1b23f 100644 (file)
@@ -172,20 +172,19 @@ public abstract class AbstractVpnRIBSupport<C extends Routes & DataObject, S ext
     }
 
     @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
index 3acc50956c4bfaf576f2befc649baf522f8c6f3e..77dfc3a337080021195232e3be59e6999486460e 100644 (file)
@@ -143,8 +143,8 @@ public class L3vpnMcastIpv4RIBSupportTest extends AbstractRIBSupportTest<L3vpnMc
 
     @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
index 7c61eb3c5a3b359e1efa3811f0f994cd21be41e9..85517d6722b23413301a5191abf0c7da1407f148 100644 (file)
@@ -143,7 +143,7 @@ public class L3vpnMcastIpv6RIBSupportTest extends AbstractRIBSupportTest<L3vpnMc
 
     @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()));
     }
 
index c38927b7bcf8a9b5aef9ed29f81c7b2e0656aa3a..101a80c5d0cb96b8ae24cedc4c0089ce21366ca8 100644 (file)
@@ -122,7 +122,8 @@ public class VpnIpv4RIBSupportTest extends AbstractRIBSupportTest<VpnIpv4RoutesC
 
     @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
index 6dfd727902aed7428b97564fab9135fdd48474fe..395ea3016396882c8cac644092951eeb78c2670d 100644 (file)
@@ -121,7 +121,8 @@ public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest<VpnIpv6RoutesC
 
     @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
index 04b90f36bdbed61c7fc0473074b5e5f1660901dd..7ddffe0bc118536e08dec98f08ea4a84a4503479 100644 (file)
@@ -171,21 +171,20 @@ abstract class AbstractLabeledUnicastRIBSupport<
     }
 
     @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
index bbca7c4487934ef34501251c56950ada1a79e53d..6234f8268498231eb9cd73ebc13c249a4de762ed 100644 (file)
@@ -153,7 +153,7 @@ public class LabeledUnicastIpv4RIBSupportTest extends AbstractRIBSupportTest<Lab
 
     @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
index d5fb7a4e2ac471ae125c1e3b0cfef5392d49e60c..1c614a7b3dc9925ae05ddbe0f06cfae0217c28ba 100644 (file)
@@ -151,7 +151,7 @@ public class LabeledUnicastIpv6RIBSupportTest extends AbstractRIBSupportTest<Lab
 
     @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
index 4d0e30b5ddf0267976e43310cd242b0678ff81a4..a35fd31f363cae9cf06434a735f85ca8b72d2db2 100644 (file)
@@ -147,15 +147,15 @@ public final class LinkstateRIBSupport
     }
 
     @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
@@ -169,8 +169,8 @@ public final class LinkstateRIBSupport
     }
 
     @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
index 8f3caf2edd773cf735b9be8bd72241024c20c26e..b3b038724b1bbe2960039a24cb22cf1ceb73f6b7 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.collect.ImmutableSet;
 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;
@@ -168,7 +167,7 @@ public final class LinkstateRIBSupportTest extends AbstractRIBSupportTest<Linkst
 
     @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()));
     }
 
index 042564c24a648fa14dab11ddf8ede8fca8b399a1..7cd5d93b2f47f74eb3f06182bb580d4da5f3d14d 100644 (file)
@@ -88,20 +88,19 @@ abstract class AbstractMvpnRIBSupport<C extends Routes & DataObject & ChoiceIn<T
     }
 
     @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
index 968ea55f6c39fd6b331ac222423371f72abd0ce9..c6d0f172674e9df6310b2dcad8363503e042c7b9 100644 (file)
@@ -144,8 +144,7 @@ public class MvpnIpv4RIBSupportTest extends AbstractRIBSupportTest<MvpnRoutesIpv
 
     @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
index 44939a546477609f8d9fe8d23ffc9ad199f0c14a..54f4be690f7a0f6e7fa5570b48ea9634707e14ae 100644 (file)
@@ -146,8 +146,7 @@ public final class MvpnIpv6RIBSupportTest extends AbstractRIBSupportTest<MvpnRou
 
     @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
index 4f76384db46cffadab7a0b1ba9c375fbecc70928..fcf99241ad85521f555f3020066b4074baada798 100644 (file)
@@ -192,21 +192,17 @@ public final class RouteTargetConstrainRIBSupport
     }
 
     @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;
@@ -218,10 +214,9 @@ public final class RouteTargetConstrainRIBSupport
         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
index 4e7b0edf3956343cb6d8d5cce3fd244a34532b1c..f38ac50265a5dadb550b09994f86a0acb979f216 100644 (file)
@@ -157,8 +157,7 @@ public class RouteTargetConstrainRIBSupportTest extends AbstractRIBSupportTest<R
 
     @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
index d54695f093c25214e41ef5e8e5b7569ce2bbdc3b..3b49d222d3141ad93be8051a0c2f355018fd6358 100644 (file)
@@ -7,6 +7,9 @@
  */
 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;
@@ -22,6 +25,7 @@ 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.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;
@@ -60,11 +64,11 @@ public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject &
     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
@@ -127,7 +131,7 @@ public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject &
         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,
@@ -146,7 +150,7 @@ public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject &
         }
         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);
@@ -227,4 +231,8 @@ public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject &
             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);
+    }
 }
index 0243a33c80a7c309df520a0f12c00fbefa8539e7..14052e424f848fed3162473cb6e466e66d389461 100644 (file)
@@ -8,6 +8,7 @@
 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;
@@ -18,7 +19,6 @@ import org.opendaylight.protocol.bgp.rib.spi.RouterIds;
 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) {
@@ -38,7 +38,7 @@ final class BaseBestPath extends AbstractBestPath {
 
     @Override
     public long getPathId() {
-        return PATH_ID;
+        return NON_PATH_ID_VALUE;
     }
 
     @Override
index 22561e4fadfe3e2faf2fcf8e636d7403e7e8da78..17d2871f025850bcb197947720b1dc911f8ca115 100644 (file)
@@ -54,10 +54,10 @@ final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
         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
@@ -121,7 +121,7 @@ final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
         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);
@@ -134,7 +134,7 @@ final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
         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()));
     }
index 7df17d0d973146b150444758cb813d70d94a16fe..3b11484ad44ebe7332daf4eb94243b82d4c48dab 100644 (file)
@@ -7,8 +7,6 @@
  */
 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;
@@ -37,8 +35,8 @@ import org.opendaylight.protocol.bgp.rib.spi.Peer;
 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;
@@ -224,7 +222,7 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
             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;
@@ -272,7 +270,7 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
     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;
@@ -297,11 +295,12 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
         }, 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;
@@ -368,7 +367,7 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
 
         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();
@@ -406,15 +405,16 @@ abstract class AbstractPeer extends BGPPeerStateImpl implements BGPRouteEntryImp
             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);
     }
index d28b9f7c8fe7aa267324c1889f5d14cf80bbddd7..cf6842e762d5a2ea581457bc8a0d7036c2394787 100644 (file)
@@ -77,7 +77,7 @@ public class GracefulRestartTest extends AbstractAddPathTest {
     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");
@@ -128,6 +128,7 @@ public class GracefulRestartTest extends AbstractAddPathTest {
         this.session = createPeerSession(PEER1, parameters, this.listener);
     }
 
+    @Override
     @After
     public void tearDown() throws ExecutionException, InterruptedException {
         waitFutureSuccess(this.serverChannel.close());
@@ -381,11 +382,11 @@ public class GracefulRestartTest extends AbstractAddPathTest {
         });
     }
 
-    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) {
@@ -395,7 +396,7 @@ public class GracefulRestartTest extends AbstractAddPathTest {
         }
 
         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()));
@@ -404,7 +405,7 @@ public class GracefulRestartTest extends AbstractAddPathTest {
         }
 
         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()));
@@ -413,7 +414,7 @@ public class GracefulRestartTest extends AbstractAddPathTest {
         }
     }
 
-    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);
index 8ae761a3e5815c674cf784e3e70b9183202c396b..441565b4ac3afc23126ad08798272a9108e26c3e 100644 (file)
@@ -11,6 +11,7 @@ import java.util.ArrayList;
 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;
@@ -21,7 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
 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;
@@ -74,7 +74,7 @@ final class PeerUtil {
         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;
@@ -86,7 +86,7 @@ final class PeerUtil {
             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();
@@ -98,7 +98,7 @@ final class PeerUtil {
             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();
index 9b5c981036dc79085692ccc432c93eb3e397bd7f..7a4fa5145694997a1ac9161e0c31e52b9b3cce69 100644 (file)
@@ -7,7 +7,7 @@
  */
 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;
@@ -16,6 +16,7 @@ import java.util.List;
 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;
@@ -237,13 +238,12 @@ public interface RIBSupport<
      * 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.
@@ -287,16 +287,16 @@ public interface RIBSupport<
      * @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);
     }
 }
index bc9b27fa6f78f4c1933e0fccc9ff3a3f84500ede..09775890707cb2abe6773615faccd30bef5590a4 100644 (file)
@@ -48,7 +48,8 @@ public abstract class AbstractAdvertizedRoute<C extends Routes & DataObject & Ch
 
         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() {
index 1326816f1159fe438eba1d69bb678009a2b897cf..43b2543d37532c837bd82761cd2269252a5bfe70 100644 (file)
@@ -13,7 +13,9 @@ import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VA
 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;
@@ -45,10 +47,10 @@ public final class StaleBestPathRoute<C extends Routes & DataObject & ChoiceIn<T
             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();
@@ -91,4 +93,8 @@ public final class StaleBestPathRoute<C extends Routes & DataObject & ChoiceIn<T
     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);
+    }
 }
index 49c60c08d9961802739f6e4f2027017e7b6f233e..e9f0f0ec3a2f08b301de432cfb0190ce2b85f501 100644 (file)
@@ -65,8 +65,7 @@ public final class RIBSupportTestImp extends AbstractRIBSupport<Ipv4RoutesCase,
     }
 
     @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;
     }
 
@@ -81,8 +80,8 @@ public final class RIBSupportTestImp extends AbstractRIBSupport<Ipv4RoutesCase,
     }
 
     @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