Fix findbug and checkstyle issues 72/66972/2
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 9 Jan 2018 11:51:34 +0000 (12:51 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 9 Jan 2018 13:50:52 +0000 (14:50 +0100)
Change-Id: Ia8fef246d76af79c9557f7cecf7cbd2740249ab9
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
36 files changed:
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/PathIdUtil.java
bgp/path-selection-mode/pom.xml
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/BesthPathStateUtil.java [new file with mode: 0644]
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/api/BestPath.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/api/PathSelectionMode.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/api/RouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/BestPathStateImpl.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/add/AddPathBestPath.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathSelector.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/OffsetMap.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/RouteKey.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/all/paths/AbstractAllPathsRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/all/paths/ComplexRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/all/paths/SimpleRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/AbstractNPathsRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/AddPathBestNPathSelection.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/ComplexRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/SimpleRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseAbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseComplexRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/OffsetMap.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractBestPath.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractBestPathSelector.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/RouteEntryUtil.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/AbstractRouteEntryTest.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/add/all/paths/SimpleRouteEntryTest.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/SimpleRouteEntryTest.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseBestPathTest.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/base/BasePathSelectorTest.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseRouteEntryTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RouteUpdateKey.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/ExportPolicyPeerTracker.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AddPathRibSupportTest.java

index cca87d6bc7ddd23b8a0970a241c3237f3dd53176..9fe8c3204426569372b1346d46f09be23917fcd6 100644 (file)
@@ -70,22 +70,23 @@ public final class PathIdUtil {
     }
 
     /**
-     * Create a Add Path PathArgument Key(prefix+pathId)
+     * Create a Add Path PathArgument Key(prefix+pathId).
      *
-     * @param pathId Path Id value
-     * @param routeId Route Id value
-     * @param routeQname route QName provided per each RibSupport
-     * @param pathidQname Path Id QName provided per each RibSupport
+     * @param pathId        Path Id value
+     * @param routeId       Route Id value
+     * @param routeQname    route QName provided per each RibSupport
+     * @param pathidQname   Path Id QName provided per each RibSupport
      * @param routeKeyQname Prefix QName provided per each RibSupport
      * @return Route Key Nid
      */
-    public static PathArgument createNidKey(final long pathId, final PathArgument routeId, final QName routeQname, final QName pathidQname,
-        final QName routeKeyQname) {
-        return createNodeIdentifierWithPredicates(routeQname, pathidQname, pathId, routeKeyQname, getObjectKey(routeId, routeKeyQname));
+    public static NodeIdentifierWithPredicates createNidKey(final long pathId, final PathArgument routeId,
+        final QName routeQname, final QName pathidQname, final QName routeKeyQname) {
+        return createNodeIdentifierWithPredicates(routeQname, pathidQname, pathId, routeKeyQname,
+            getObjectKey(routeId, routeKeyQname));
     }
 
     /**
-     * Get route key object ( prefgit stat  ix / key-value/ .. )
+     * Get route key object ( prefgit stat  ix / key-value/ .. ).
      *
      * @param routeId PathArgument containing the key
      * @param routeKeyQname routeKey Qname
@@ -95,37 +96,40 @@ public final class PathIdUtil {
         return (((NodeIdentifierWithPredicates) routeId).getKeyValues()).get(routeKeyQname);
     }
 
-    public static NodeIdentifierWithPredicates createNodeIdentifierWithPredicates(final QName routeQname, final QName pathidQname, final Object pathId,
-        final QName routeKeyQname, final Object keyObject) {
+    public static NodeIdentifierWithPredicates createNodeIdentifierWithPredicates(final QName routeQname,
+        final QName pathidQname, final Object pathId, final QName routeKeyQname, final Object keyObject) {
         final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(pathidQname, pathId, routeKeyQname, keyObject);
         return new NodeIdentifierWithPredicates(routeQname, keyValues);
     }
 
     /**
-     * Build Path Id
+     * Build Path Id.
      *
      * @param routesCont route container
      * @param pathIdNii path Id node Identifier
      * @return PathId or null in case is not the container
      */
-    public static PathId buildPathId(final DataContainerNode<? extends PathArgument> routesCont, final NodeIdentifier pathIdNii) {
+    public static PathId buildPathId(final DataContainerNode<? extends PathArgument> routesCont,
+            final NodeIdentifier pathIdNii) {
         final Long pathIdVal = PathIdUtil.extractPathId(routesCont, pathIdNii);
         return pathIdVal == null ? null : new PathId(pathIdVal);
     }
 
     /**
-     * Build Route Key for supporting mp
-     * Key is composed by 2 elements (route-key + path Id)
+     * Build Route Key for supporting mp.
+     * Key is composed by 2 elements (route-key + path Id).
      *
      * @param routeQname route Qname
      * @param routeKeyQname route key Qname
      * @param pathIdQname path Id Qname
      * @param routeKeyValue route key value
-     * @param maybePathIdLeaf path id container, it might me supported or not, in that case default 0 value will be assigned
+     * @param maybePathIdLeaf path id container, it might me supported or not, in that case default 0 value will
+     * be assigned
      * @return Route Key Nid
      */
-    public static NodeIdentifierWithPredicates createNidKey(final QName routeQname, final QName routeKeyQname, final QName pathIdQname,
-        final Object routeKeyValue, final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf) {
+    public static NodeIdentifierWithPredicates createNidKey(final QName routeQname, final QName routeKeyQname,
+            final QName pathIdQname, final Object routeKeyValue,
+            final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf) {
         // FIXME: a cache here would mean we instantiate the same identifier for each route making comparison quicker.
         final Object pathId = maybePathIdLeaf.isPresent() ? (maybePathIdLeaf.get()).getValue() : NON_PATH_ID;
         return createNodeIdentifierWithPredicates(routeQname, pathIdQname, pathId, routeKeyQname, routeKeyValue);
index 4971ae38aba9452ab8748422a3fa7ac7ef5303b7..1661b506130ac69683da7721fdd7635852038708 100644 (file)
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
diff --git a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/BesthPathStateUtil.java b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/BesthPathStateUtil.java
new file mode 100644 (file)
index 0000000..b7625ab
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.mode;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments;
+
+public final class BesthPathStateUtil {
+    BesthPathStateUtil() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static AsNumber getPeerAs(final List<Segments> segments) {
+        if (segments.isEmpty()) {
+            return new AsNumber(0L);
+        }
+        for (final Segments seg : segments) {
+            if (seg.getAsSequence() != null && !seg.getAsSequence().isEmpty()) {
+                return segments.get(0).getAsSequence().get(0);
+            }
+        }
+        return new AsNumber(0L);
+    }
+}
index 01b483b2d30d2318278e7c3fac4b07fd036bd93a..22916a85c88acc4b844366fe348e39c71a2db76f 100644 (file)
@@ -15,24 +15,28 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 public interface BestPath {
 
     /**
+     * RouterId.
      *
      * @return the routerId (UnsignedInteger)
      */
     UnsignedInteger getRouterId();
 
     /**
+     * PeerId.
      *
      * @return the routerId (UnsignedInteger) converted to a PeerId
      */
     PeerId getPeerId();
 
     /**
+     * Attributes.
      *
      * @return the path attributes
      */
     ContainerNode getAttributes();
 
     /**
+     * PathId.
      *
      * @return pathId
      */
index b1ee6a1d1a8ce7df6d848547a21d295e8e3e2541..97e408a3ba0ce25704d98577b1b584b7c71a6642 100644 (file)
@@ -7,11 +7,14 @@
  */
 package org.opendaylight.protocol.bgp.mode.api;
 
+import javax.annotation.Nonnull;
+
 public interface PathSelectionMode extends AutoCloseable {
     /**
-     * Create a RouteEntry
+     * Create a RouteEntry.
+     *
      * @param isComplex true if is complex
      * @return ComplexRouteEntry if is complex otherwise a SimpleRouteEntry
      */
-    RouteEntry createRouteEntry(boolean isComplex);
+    @Nonnull RouteEntry createRouteEntry(boolean isComplex);
 }
index 9ef78754b6419826d499bcd2384fa2c52540acac..7535b7407a5d40dc81296dcf634b4cc055ee9ed3 100644 (file)
@@ -30,25 +30,26 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
  */
 public interface RouteEntry {
     /**
-     * Remove route
+     * Remove route.
      *
-     * @param routerId router ID in unsigned integer format from an Ipv4Address
+     * @param routerId     router ID in unsigned integer format from an Ipv4Address
      * @param remotePathId remote path Id received
      * @return return true if it was the last route on entry
      */
     boolean removeRoute(UnsignedInteger routerId, Long remotePathId);
 
     /**
-     * Create value
+     * Create value.
      *
      * @param routeId router ID pathArgument
-     * @param path BestPath
+     * @param path    BestPath
      * @return MapEntryNode
      */
+    @Deprecated
     MapEntryNode createValue(PathArgument routeId, BestPath path);
 
     /**
-     * Indicates whether best has changed
+     * Indicates whether best has changed.
      *
      * @param localAs The local autonomous system number
      * @return return true if it has changed
@@ -56,37 +57,40 @@ public interface RouteEntry {
     boolean selectBest(long localAs);
 
     /**
-     * @param routerId router ID in unsigned integer format from an Ipv4Address
+     * Add Route.
+     *
+     * @param routerId     router ID in unsigned integer format from an Ipv4Address
      * @param remotePathId remote path Id received
-     * @param attrII route Attributes Identifier
-     * @param data route Data change
+     * @param attrII       route Attributes Identifier
+     * @param data         route Data change
      * @return returns the offset
      */
     int addRoute(UnsignedInteger routerId, Long remotePathId, NodeIdentifier attrII, NormalizedNode<?, ?> data);
 
     /**
-     * Update LocRibOut and AdjRibsOut by removing stale best path and writing new best
+     * Update LocRibOut and AdjRibsOut by removing stale best path and writing new best.
      *
-     * @param localTK local Table Key
-     * @param peerPT peer export policy
+     * @param localTK      local Table Key
+     * @param peerPT       peer export policy
      * @param locRibTarget YII local rib
-     * @param ribSupport rib support
-     * @param tx DOM transaction
-     * @param routeIdPA router ID pathArgument
+     * @param ribSupport   rib support
+     * @param tx           DOM transaction
+     * @param routeIdPA    router ID pathArgument
      */
-    void updateRoute(TablesKey localTK, ExportPolicyPeerTracker peerPT, YangInstanceIdentifier locRibTarget, RIBSupport ribSupport,
-        DOMDataWriteTransaction tx, PathArgument routeIdPA);
+    void updateRoute(TablesKey localTK, ExportPolicyPeerTracker peerPT, YangInstanceIdentifier locRibTarget,
+            RIBSupport ribSupport, DOMDataWriteTransaction tx, PathArgument routeIdPA);
 
     /**
-     * Write Route on LocRibOut and AdjRibsOut
-     *  @param peerId destination peerId
-     * @param routeId router ID path Argument
-     * @param rootPath YII root path
-     * @param peerGroup PeerExportGroup
-     * @param localTK local Table Key
+     * Write Route on LocRibOut and AdjRibsOut.
+     *
+     * @param peerId     destination peerId
+     * @param routeId    router ID path Argument
+     * @param rootPath   YII root path
+     * @param peerGroup  PeerExportGroup
+     * @param localTK    local Table Key
      * @param ribSupport rib support
-     * @param tx DOM transaction
+     * @param tx         DOM transaction
      */
-    void writeRoute(PeerId peerId, PathArgument routeId, YangInstanceIdentifier rootPath, PeerExportGroup peerGroup, TablesKey localTK,
-        ExportPolicyPeerTracker peerPT, RIBSupport ribSupport, DOMDataWriteTransaction tx);
+    void writeRoute(PeerId peerId, PathArgument routeId, YangInstanceIdentifier rootPath, PeerExportGroup peerGroup,
+            TablesKey localTK, ExportPolicyPeerTracker peerPT, RIBSupport ribSupport, DOMDataWriteTransaction tx);
 }
\ No newline at end of file
index 114988016c47483ed13e7343deab8b9fe90ebe3e..3a3159f0b0ed8ed07baa922c453e325c78cf2bd1 100644 (file)
@@ -20,6 +20,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import javax.annotation.concurrent.NotThreadSafe;
+import org.opendaylight.protocol.bgp.mode.BesthPathStateUtil;
 import org.opendaylight.protocol.bgp.mode.api.BestPathState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPath;
@@ -54,7 +55,8 @@ public final class BestPathStateImpl implements BestPathState {
         private final NodeIdentifier asSeqNid;
 
         NamespaceSpecificIds(final QName namespace) {
-            NodeIdentifier container = new NodeIdentifier(QName.create(namespace, AsPath.QNAME.getLocalName().intern()));
+            NodeIdentifier container = new NodeIdentifier(QName.create(namespace,
+                    AsPath.QNAME.getLocalName().intern()));
             NodeIdentifier leaf = new NodeIdentifier(QName.create(namespace, "segments").intern());
             this.asPath = ImmutableList.of(container, leaf);
 
@@ -100,7 +102,8 @@ public final class BestPathStateImpl implements BestPathState {
     }
 
     private static final Logger LOG = LoggerFactory.getLogger(BestPathStateImpl.class);
-    private static final Cache<QNameModule, NamespaceSpecificIds> PATH_CACHE = CacheBuilder.newBuilder().weakKeys().weakValues().build();
+    private static final Cache<QNameModule, NamespaceSpecificIds> PATH_CACHE = CacheBuilder.newBuilder()
+            .weakKeys().weakValues().build();
 
     private long peerAs = 0L;
     private int asPathLength = 0;
@@ -115,7 +118,8 @@ public final class BestPathStateImpl implements BestPathState {
     public BestPathStateImpl(final ContainerNode attributes) {
         final NamespaceSpecificIds col;
         try {
-            col = PATH_CACHE.get(attributes.getNodeType().getModule(), () -> new NamespaceSpecificIds(attributes.getNodeType()));
+            col = PATH_CACHE.get(attributes.getNodeType().getModule(),
+                () -> new NamespaceSpecificIds(attributes.getNodeType()));
         } catch (final ExecutionException e) {
             LOG.error("Error creating namespace-specific attributes collection.", e);
             throw new IllegalStateException("Error creating namespace-specific attributes collection.", e);
@@ -128,14 +132,14 @@ public final class BestPathStateImpl implements BestPathState {
 
     private static BgpOrigin fromString(final String originStr) {
         switch (originStr) {
-        case "igp":
-            return BgpOrigin.Igp;
-        case "egp":
-            return BgpOrigin.Egp;
-        case "incomplete":
-            return BgpOrigin.Incomplete;
-        default:
-            throw new IllegalArgumentException("Unhandled origin value " + originStr);
+            case "igp":
+                return BgpOrigin.Igp;
+            case "egp":
+                return BgpOrigin.Egp;
+            case "incomplete":
+                return BgpOrigin.Incomplete;
+            default:
+                throw new IllegalArgumentException("Unhandled origin value " + originStr);
         }
     }
 
@@ -144,33 +148,37 @@ public final class BestPathStateImpl implements BestPathState {
             return;
         }
 
-        final Optional<NormalizedNode<?, ?>> maybeLocalPref = NormalizedNodes.findNode(this.attributes, this.ids.getLocPref());
+        final Optional<NormalizedNode<?, ?>> maybeLocalPref
+                = NormalizedNodes.findNode(this.attributes, this.ids.getLocPref());
         if (maybeLocalPref.isPresent()) {
             this.localPref = (Long) maybeLocalPref.get().getValue();
         } else {
             this.localPref = null;
         }
 
-        final Optional<NormalizedNode<?, ?>> maybeMultiExitDisc = NormalizedNodes.findNode(this.attributes, this.ids.getMed());
+        final Optional<NormalizedNode<?, ?>> maybeMultiExitDisc
+                = NormalizedNodes.findNode(this.attributes, this.ids.getMed());
         if (maybeMultiExitDisc.isPresent()) {
             this.multiExitDisc = (Long) maybeMultiExitDisc.get().getValue();
         } else {
             this.multiExitDisc = null;
         }
 
-        final Optional<NormalizedNode<?, ?>> maybeOrigin = NormalizedNodes.findNode(this.attributes, this.ids.getOrig());
+        final Optional<NormalizedNode<?, ?>> maybeOrigin
+                = NormalizedNodes.findNode(this.attributes, this.ids.getOrig());
         if (maybeOrigin.isPresent()) {
             this.origin = fromString((String) maybeOrigin.get().getValue());
         } else {
             this.origin = null;
         }
 
-        final Optional<NormalizedNode<?, ?>> maybeSegments = NormalizedNodes.findNode(this.attributes, this.ids.getAsPath());
+        final Optional<NormalizedNode<?, ?>> maybeSegments
+                = NormalizedNodes.findNode(this.attributes, this.ids.getAsPath());
         if (maybeSegments.isPresent()) {
             final UnkeyedListNode segments = (UnkeyedListNode) maybeSegments.get();
             final List<Segments> segs = extractSegments(segments);
             if (!segs.isEmpty()) {
-                this.peerAs = getPeerAs(segs).getValue();
+                this.peerAs = BesthPathStateUtil.getPeerAs(segs).getValue();
                 this.asPathLength = countAsPath(segs);
             }
         }
@@ -222,25 +230,17 @@ public final class BestPathStateImpl implements BestPathState {
         return count;
     }
 
-    private static AsNumber getPeerAs(final List<Segments> segments) {
-        if (segments.isEmpty()) {
-            return new AsNumber(0L);
-        }
-        for (final Segments seg : segments) {
-            if (seg.getAsSequence() != null && !seg.getAsSequence().isEmpty()) {
-                return segments.get(0).getAsSequence().get(0);
-            }
-        }
-        return new AsNumber(0L);
-    }
+
 
     public List<Segments> extractSegments(final UnkeyedListNode segments) {
         // list segments
         final List<Segments> extracted = new ArrayList<>();
         for (final UnkeyedListEntryNode segment : segments.getValue()) {
             final SegmentsBuilder sb = new SegmentsBuilder();
-            // We are expecting that segment contains either as-sequence or as-set, so just one of them will be set, other would be null
-            sb.setAsSequence(extractAsList(segment, this.ids.getAsSeq())).setAsSet(extractAsList(segment, this.ids.getAsSet()));
+            // We are expecting that segment contains either as-sequence or as-set,
+            // so just one of them will be set, other would be null
+            sb.setAsSequence(extractAsList(segment, this.ids.getAsSeq()))
+                    .setAsSet(extractAsList(segment, this.ids.getAsSet()));
             extracted.add(sb.build());
         }
         return extracted;
index 6609e556b2630c1c309fe8fc4c0d8682dee80c6d..0f156347a25c4faff47b3692529cb9ddda647f64 100644 (file)
@@ -89,14 +89,16 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
         return offset;
     }
 
-    protected int addRoute(final RouteKey key, final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
+    protected int addRoute(final RouteKey key, final NodeIdentifier attributesIdentifier,
+            final NormalizedNode<?, ?> data) {
         LOG.trace("Find {} in {}", attributesIdentifier, data);
-        final ContainerNode advertisedAttrs = (ContainerNode) NormalizedNodes.findNode(data, attributesIdentifier).orNull();
+        final ContainerNode advertisedAttrs
+                = (ContainerNode) NormalizedNodes.findNode(data, attributesIdentifier).orNull();
         return addRoute(key, advertisedAttrs);
     }
 
     /**
-     * Remove route
+     * Remove route.
      *
      * @param key RouteKey of removed route
      * @param offset Offset of removed route
@@ -107,7 +109,7 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
         this.values = this.offsets.removeValue(this.values, offset);
         this.pathsId = this.offsets.removeValue(this.pathsId, offset);
         this.offsets = this.offsets.without(key);
-        if(this.removedPaths == null) {
+        if (this.removedPaths == null) {
             this.removedPaths = new ArrayList<>();
         }
         this.removedPaths.add(new RemovedPath(key, pathId));
@@ -115,71 +117,84 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
     }
 
     @Override
-    public void updateRoute(final TablesKey localTK, final ExportPolicyPeerTracker peerPT, final YangInstanceIdentifier locRibTarget,
-        final RIBSupport ribSupport, final DOMDataWriteTransaction tx, final PathArgument routeIdPA) {
-        if(this.bestPathRemoved != null) {
+    public void updateRoute(final TablesKey localTK, final ExportPolicyPeerTracker peerPT,
+            final YangInstanceIdentifier locRibTarget, final RIBSupport ribSupport, final DOMDataWriteTransaction tx,
+            final PathArgument routeIdPA) {
+        if (this.bestPathRemoved != null) {
             this.bestPathRemoved.forEach(path -> {
                 final PathArgument routeIdAddPath = ribSupport.getRouteIdAddPath(path.getPathId(), routeIdPA);
-                final YangInstanceIdentifier pathAddPathTarget = ribSupport.routePath(locRibTarget.node(ROUTES_IDENTIFIER), routeIdAddPath);
+                final YangInstanceIdentifier pathAddPathTarget = ribSupport
+                        .routePath(locRibTarget.node(ROUTES_IDENTIFIER), routeIdAddPath);
                 fillLocRib(pathAddPathTarget, null, tx);
             });
             this.bestPathRemoved = null;
         }
-        if(this.removedPaths != null) {
+        if (this.removedPaths != null) {
             this.removedPaths.forEach(removedPath -> {
                 final PathArgument routeIdAddPath = ribSupport.getRouteIdAddPath(removedPath.getPathId(), routeIdPA);
-                fillAdjRibsOut(true, null, null, null, routeIdPA, routeIdAddPath, RouterIds.createPeerId(removedPath.getRouteId()),
-                    peerPT, localTK, ribSupport, tx);
+                fillAdjRibsOut(true, null, null, null, routeIdPA, routeIdAddPath,
+                        RouterIds.createPeerId(removedPath.getRouteId()), peerPT, localTK, ribSupport, tx);
             });
             this.removedPaths = null;
         }
 
-        if(this.newBestPathToBeAdvertised != null) {
-            this.newBestPathToBeAdvertised.forEach(path -> addPathToDataStore(path, isFirstBestPath(this.bestPath.indexOf(path)), routeIdPA,
-                locRibTarget, ribSupport, peerPT, localTK, tx));
+        if (this.newBestPathToBeAdvertised != null) {
+            this.newBestPathToBeAdvertised.forEach(path -> addPathToDataStore(path,
+                    isFirstBestPath(this.bestPath.indexOf(path)), routeIdPA, locRibTarget, ribSupport, peerPT,
+                    localTK, tx));
             this.newBestPathToBeAdvertised = null;
         }
     }
 
     @Override
-    public void writeRoute(final PeerId destPeer, final PathArgument routeId, final YangInstanceIdentifier rootPath, final PeerExportGroup peerGroup,
-        final TablesKey localTK, final ExportPolicyPeerTracker peerPT, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
+    public void writeRoute(final PeerId destPeer, final PathArgument routeId, final YangInstanceIdentifier rootPath,
+            final PeerExportGroup peerGroup, final TablesKey localTK, final ExportPolicyPeerTracker peerPT,
+            final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
         final boolean destPeerSupAddPath = peerPT.isAddPathSupportedByPeer(destPeer);
-        if(this.bestPath != null) {
+        if (this.bestPath != null) {
             final PeerRole destPeerRole = getRoutePeerIdRole(peerPT, destPeer);
-            this.bestPath.stream().filter(path -> filterRoutes(path.getPeerId(), destPeer, peerPT, localTK, destPeerRole) &&
-                peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath(this.bestPath.indexOf(path))))
-                .forEach(path -> writeRoutePath(destPeer, routeId, peerPT, peerGroup, destPeerSupAddPath, path, rootPath, localTK, ribSup, tx));
+            this.bestPath.stream().filter(path -> filterRoutes(path.getPeerId(), destPeer, peerPT, localTK,
+                    destPeerRole) && peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath,
+                    isFirstBestPath(this.bestPath.indexOf(path)))).forEach(path -> writeRoutePath(destPeer, routeId,
+                    peerPT, peerGroup, destPeerSupAddPath, path, rootPath, localTK, ribSup, tx));
         }
     }
 
     private void writeRoutePath(final PeerId destPeer, final PathArgument routeId, final ExportPolicyPeerTracker peerPT,
-        final PeerExportGroup peerGroup, final boolean destPeerSupAddPath,
-        final BestPath path, final YangInstanceIdentifier rootPath, final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
+        final PeerExportGroup peerGroup, final boolean destPeerSupAddPath, final BestPath path,
+            final YangInstanceIdentifier rootPath, final TablesKey localTK, final RIBSupport ribSup,
+            final DOMDataWriteTransaction tx) {
         final PathArgument routeIdAddPath = ribSup.getRouteIdAddPath(path.getPathId(), routeId);
-        final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT,path.getPeerId()), path.getAttributes());
+        final ContainerNode effectiveAttributes = peerGroup
+                .effectiveAttributes(getRoutePeerIdRole(peerPT,path.getPeerId()), path.getAttributes());
         if (destPeerSupAddPath) {
-            writeRoute(destPeer, getAdjRibOutYII(ribSup, rootPath, routeIdAddPath, localTK), effectiveAttributes, createValue(routeIdAddPath, path), ribSup, tx);
+            writeRoute(destPeer, getAdjRibOutYII(ribSup, rootPath, routeIdAddPath, localTK), effectiveAttributes,
+                    createValue(routeIdAddPath, path), ribSup, tx);
         } else {
-            writeRoute(destPeer, getAdjRibOutYII(ribSup, rootPath, routeId, localTK), effectiveAttributes, createValue(routeId, path), ribSup, tx);
+            writeRoute(destPeer, getAdjRibOutYII(ribSup, rootPath, routeId, localTK), effectiveAttributes,
+                    createValue(routeId, path), ribSup, tx);
         }
     }
 
-    private void addPathToDataStore(final BestPath path, final boolean isFirstBestPath, final PathArgument routeIdPA, final YangInstanceIdentifier locRibTarget,
-        final RIBSupport ribSup, final ExportPolicyPeerTracker peerPT, final TablesKey localTK, final DOMDataWriteTransaction tx) {
+    private void addPathToDataStore(final BestPath path, final boolean isFirstBestPath, final PathArgument routeIdPA,
+            final YangInstanceIdentifier locRibTarget, final RIBSupport ribSup, final ExportPolicyPeerTracker peerPT,
+            final TablesKey localTK, final DOMDataWriteTransaction tx) {
         final PathArgument routeIdAddPath = ribSup.getRouteIdAddPath(path.getPathId(), routeIdPA);
-        final YangInstanceIdentifier pathAddPathTarget = ribSup.routePath(locRibTarget.node(ROUTES_IDENTIFIER), routeIdAddPath);
+        final YangInstanceIdentifier pathAddPathTarget = ribSup.routePath(locRibTarget.node(ROUTES_IDENTIFIER),
+                routeIdAddPath);
         final MapEntryNode addPathValue = createValue(routeIdAddPath, path);
         final MapEntryNode value = createValue(routeIdPA, path);
         LOG.trace("Selected best value {}", addPathValue);
         fillLocRib(pathAddPathTarget, addPathValue, tx);
-        fillAdjRibsOut(isFirstBestPath, path.getAttributes(), value, addPathValue, routeIdPA, routeIdAddPath, path.getPeerId(), peerPT, localTK,
+        fillAdjRibsOut(isFirstBestPath, path.getAttributes(), value, addPathValue, routeIdPA, routeIdAddPath,
+                path.getPeerId(), peerPT, localTK,
             ribSup, tx);
     }
 
-    private void fillAdjRibsOut(final boolean isFirstBestPath, final ContainerNode attributes, final NormalizedNode<?, ?> value, final MapEntryNode addPathValue,
-        final PathArgument routeId, final PathArgument routeIdAddPath, final PeerId routePeerId, final ExportPolicyPeerTracker peerPT, final TablesKey
-        localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
+    private void fillAdjRibsOut(final boolean isFirstBestPath, final ContainerNode attributes,
+            final NormalizedNode<?, ?> value, final MapEntryNode addPathValue, final PathArgument routeId,
+            final PathArgument routeIdAddPath, final PeerId routePeerId, final ExportPolicyPeerTracker peerPT,
+            final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
         /*
          * We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
          * expose from which client a particular route was learned from in the local RIB, and have
@@ -192,16 +207,18 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
         for (final PeerRole role : PeerRole.values()) {
             final PeerExportGroup peerGroup = peerPT.getPeerGroup(role);
             if (peerGroup != null) {
-                final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT, routePeerId), attributes);
+                final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT,
+                        routePeerId), attributes);
                 peerGroup.forEach((destPeer, rootPath) -> {
                     final boolean destPeerSupAddPath = peerPT.isAddPathSupportedByPeer(destPeer);
-                    if (filterRoutes(routePeerId, destPeer, peerPT, localTK, role) &&
-                        peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) {
+                    if (filterRoutes(routePeerId, destPeer, peerPT, localTK, role)
+                            && peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) {
                         if (destPeerSupAddPath) {
-                            update(destPeer, getAdjRibOutYII(ribSup, rootPath, routeIdAddPath, localTK), effectiveAttributes,
-                                addPathValue, ribSup, tx);
-                        } else if(!this.oldNonAddPathBestPathTheSame){
-                            update(destPeer, getAdjRibOutYII(ribSup, rootPath, routeId, localTK), effectiveAttributes, value, ribSup, tx);
+                            update(destPeer, getAdjRibOutYII(ribSup, rootPath, routeIdAddPath, localTK),
+                                    effectiveAttributes, addPathValue, ribSup, tx);
+                        } else if (!this.oldNonAddPathBestPathTheSame) {
+                            update(destPeer, getAdjRibOutYII(ribSup, rootPath, routeId, localTK),
+                                    effectiveAttributes, value, ribSup, tx);
                         }
                     }
                 });
@@ -227,7 +244,7 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
     }
 
     /**
-     * Process best path selection
+     * Process best path selection.
      *
      * @param localAs The local autonomous system number
      * @param keyList List of RouteKey
@@ -255,9 +272,10 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
     protected boolean isBestPathNew(final List<AddPathBestPath> newBestPathList) {
         this.oldNonAddPathBestPathTheSame = isNonAddPathBestPathTheSame(newBestPathList);
         filterRemovedPaths(newBestPathList);
-        if (this.bestPathRemoved != null && !this.bestPathRemoved.isEmpty() || newBestPathList != null && !newBestPathList.equals(this.bestPath)) {
+        if (this.bestPathRemoved != null && !this.bestPathRemoved.isEmpty() || newBestPathList != null
+                && !newBestPathList.equals(this.bestPath)) {
             this.newBestPathToBeAdvertised = new ArrayList<>(newBestPathList);
-            if(this.bestPath != null) {
+            if (this.bestPath != null) {
                 this.newBestPathToBeAdvertised.removeAll(this.bestPath);
             }
             this.bestPath = newBestPathList;
@@ -268,8 +286,8 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
     }
 
     private boolean isNonAddPathBestPathTheSame(final List<AddPathBestPath> newBestPathList) {
-        return !(isEmptyOrNull(this.bestPath) || isEmptyOrNull(newBestPathList)) &&
-            this.bestPath.get(0).equals(newBestPathList.get(0));
+        return !(isEmptyOrNull(this.bestPath) || isEmptyOrNull(newBestPathList))
+                && this.bestPath.get(0).equals(newBestPathList.get(0));
     }
 
     private static boolean isEmptyOrNull(final List<AddPathBestPath> pathList) {
@@ -277,13 +295,14 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry {
     }
 
     private void filterRemovedPaths(final List<AddPathBestPath> newBestPathList) {
-        if(this.bestPath == null) {
+        if (this.bestPath == null) {
             return;
         }
         this.bestPathRemoved = new ArrayList<>(this.bestPath);
         this.bestPath.forEach(oldBest -> {
             final Optional<AddPathBestPath> present = newBestPathList.stream()
-                .filter(newBest -> newBest.getPathId() == oldBest.getPathId() && newBest.getRouteKey() == oldBest.getRouteKey()).findAny();
+                    .filter(newBest -> newBest.getPathId() == oldBest.getPathId()
+                            && newBest.getRouteKey() == oldBest.getRouteKey()).findAny();
             present.ifPresent(addPathBestPath -> this.bestPathRemoved.remove(oldBest));
         });
     }
index e1981247b764c65eee42d868bd064a3aeffaefd1..13f6f4796f1851888ca9b738c9801eb5b6137407 100644 (file)
@@ -22,7 +22,8 @@ public final class AddPathBestPath extends AbstractBestPath {
     private final int offsetPosition;
     private final long pathId;
 
-    public AddPathBestPath(@Nonnull final BestPathState state, @Nonnull final RouteKey key, final int offsetPosition, final Long pathId) {
+    public AddPathBestPath(@Nonnull final BestPathState state, @Nonnull final RouteKey key, final int offsetPosition,
+            final Long pathId) {
         super(state);
         this.routeKey = requireNonNull(key);
         this.offsetPosition = offsetPosition;
@@ -64,8 +65,8 @@ public final class AddPathBestPath extends AbstractBestPath {
             return false;
         }
         /*
-        We don't check offset position since it will change as new path is added, and we want to be able to use List comparison between old
-        bestpath list and new best path list.
+        We don't check offset position since it will change as new path is added, and we want to be able
+        to use List comparison between old bestpath list and new best path list.
         */
         if (!this.state.equals(other.state)) {
             return false;
@@ -75,12 +76,12 @@ public final class AddPathBestPath extends AbstractBestPath {
     }
 
     @Override
-    public final UnsignedInteger getRouterId() {
+    public UnsignedInteger getRouterId() {
         return this.routeKey.getRouteId();
     }
 
     @Override
-    public final PeerId getPeerId() {
+    public PeerId getPeerId() {
         return RouterIds.createPeerId(this.routeKey.getRouteId());
     }
 
index 9dbe31b06945bce23e855a5800ea4f4567481f1e..380e9058041f1e722cb13238bdda91893d8f1a49 100644 (file)
@@ -52,6 +52,7 @@ public final class AddPathSelector extends AbstractBestPathSelector {
     }
 
     public AddPathBestPath result() {
-        return this.bestRouteKey == null ? null : new AddPathBestPath(this.bestState, this.bestRouteKey, this.bestOffsetPosition, this.bestPathId);
+        return this.bestRouteKey == null ? null : new AddPathBestPath(this.bestState, this.bestRouteKey,
+                this.bestOffsetPosition, this.bestPathId);
     }
 }
index ae57d35147e515a6bedc4475d71c7c2e7bac4e0c..9887dd3bd60ec5f8b9fa51e072fb2db7b2de4529 100644 (file)
@@ -32,18 +32,19 @@ import org.slf4j.LoggerFactory;
  * array members and array management features.
  */
 public final class OffsetMap {
-    static final OffsetMap EMPTY = new OffsetMap(Collections.emptySet());
     private static final Logger LOG = LoggerFactory.getLogger(OffsetMap.class);
     private static final String NEGATIVEOFFSET = "Invalid negative offset %s";
     private static final String INVALIDOFFSET = "Invalid offset %s for %s router IDs";
-    private static final LoadingCache<Set<RouteKey>, OffsetMap> OFFSETMAPS = CacheBuilder.newBuilder().weakValues().build(
-        new CacheLoader<Set<RouteKey>, OffsetMap>() {
-            @Override
-            public OffsetMap load(@Nonnull final Set<RouteKey> key) throws Exception {
-                return new OffsetMap(key);
-            }
-        });
+    private static final LoadingCache<Set<RouteKey>, OffsetMap> OFFSETMAPS = CacheBuilder.newBuilder().weakValues()
+        .build(new CacheLoader<Set<RouteKey>, OffsetMap>() {
+                @Override
+                public OffsetMap load(@Nonnull final Set<RouteKey> key) {
+                    return new OffsetMap(key);
+                }
+            });
     private static final Comparator<RouteKey> COMPARATOR = RouteKey::compareTo;
+    static final OffsetMap EMPTY = new OffsetMap(Collections.emptySet());
+
     private final RouteKey[] routeKeys;
 
     private OffsetMap(final Set<RouteKey> routerIds) {
index 9e1211c6b9d9e184acff380478b183a70d5faeb5..faf54d9d1d79c0895d30b93da240f2f915028275 100644 (file)
@@ -17,7 +17,7 @@ public final class RouteKey implements Comparable<RouteKey> {
 
     public RouteKey(final UnsignedInteger routerId, final Long remotePathId) {
         this.routerId = routerId;
-        this.remotePathId = remotePathId == null ? 0 : remotePathId;
+        this.remotePathId = remotePathId != null ? remotePathId : 0;
     }
 
     private Long getExternalPathId() {
@@ -65,6 +65,7 @@ public final class RouteKey implements Comparable<RouteKey> {
     @Override
     public int compareTo(@Nonnull final RouteKey otherRouteKey) {
         final int routeIdCompareTo = this.routerId.compareTo(otherRouteKey.getRouteId());
-        return routeIdCompareTo == 0 ? this.remotePathId.compareTo(otherRouteKey.getExternalPathId()) : routeIdCompareTo;
+        return routeIdCompareTo == 0 ? this.remotePathId.compareTo(otherRouteKey.getExternalPathId())
+                : routeIdCompareTo;
     }
 }
index bba334b24616a7b67082ea73e73e7271e8a1fec4..775f7f563523f3bfa66e58e061a7a3a10ea56bdb 100644 (file)
@@ -38,7 +38,8 @@ abstract class AbstractAllPathsRouteEntry extends AddPathAbstractRouteEntry {
                 requireNonNull(key.getRouteId(), "Router ID may not be null");
                 if (attributes != null) {
                     final BestPathState state = new BestPathStateImpl(attributes);
-                    final AddPathBestPath bestPath = new AddPathBestPath(state, key, offset, this.offsets.getValue(this.pathsId, offset));
+                    final AddPathBestPath bestPath = new AddPathBestPath(state, key, offset,
+                            this.offsets.getValue(this.pathsId, offset));
                     newBestPathList.add(bestPath);
                 }
             }
index 2ec4f43a90678fb806465b895d6dd78a31682fad..2c829c4ad95349a5d246d5654336bb54400d77a0 100644 (file)
@@ -14,7 +14,8 @@ import org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath;
 import org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap;
 import org.opendaylight.protocol.bgp.mode.impl.add.RouteKey;
 import org.opendaylight.protocol.bgp.mode.spi.RouteEntryUtil;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
@@ -32,14 +33,15 @@ final class ComplexRouteEntry extends AbstractAllPathsRouteEntry {
     }
 
     @Override
-    public MapEntryNode createValue(final YangInstanceIdentifier.PathArgument routeId, final BestPath path) {
+    public MapEntryNode createValue(final PathArgument routeId, final BestPath path) {
         final OffsetMap map = getOffsets();
         final MapEntryNode mapValues = map.getValue(this.values, map.offsetOf(((AddPathBestPath) path).getRouteKey()));
         return RouteEntryUtil.createComplexRouteValue(routeId, path, mapValues);
     }
 
     @Override
-    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final YangInstanceIdentifier.NodeIdentifier attII, final NormalizedNode<?, ?> data) {
+    public int addRoute(final UnsignedInteger routerId, final Long remotePathId,
+            final NodeIdentifier attII, final NormalizedNode<?, ?> data) {
         final OffsetMap oldMap = getOffsets();
         final int offset = addRoute(new RouteKey(routerId, remotePathId), attII, data);
         final OffsetMap newMap = getOffsets();
index 20d02c2c14a64f3ba326e4a8125e3b39c7842afb..4d01b8bba99d12a2db6ac847f70c3934e5c5234a 100644 (file)
@@ -30,7 +30,8 @@ final class SimpleRouteEntry extends AbstractAllPathsRouteEntry {
     }
 
     @Override
-    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attII, final NormalizedNode<?, ?> data) {
+    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attII,
+            final NormalizedNode<?, ?> data) {
         return addRoute(new RouteKey(routerId, remotePathId), attII, data);
     }
 }
index 0fda7d7b6ea545e4e6e41af5ae37243906e27c26..57a9d90c9cabd6e1cfc76b3e3a5318f2f36946cc 100644 (file)
@@ -16,17 +16,18 @@ import org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath;
 import org.opendaylight.protocol.bgp.mode.impl.add.RouteKey;
 
 abstract class AbstractNPathsRouteEntry extends AddPathAbstractRouteEntry {
-    private final long nBestPaths;
+    private final long npaths;
 
-    AbstractNPathsRouteEntry(final Long nBestPaths) {
-        this.nBestPaths = nBestPaths;
+    AbstractNPathsRouteEntry(final Long npaths) {
+        this.npaths = npaths;
     }
 
     @Override
     public final boolean selectBest(final long localAs) {
         final List<AddPathBestPath> newBestPathList = new ArrayList<>();
         final List<RouteKey> keyList = this.offsets.getRouteKeysList();
-        final long maxSearch = this.nBestPaths < this.offsets.size() && this.nBestPaths != 0 ? this.nBestPaths : this.offsets.size();
+        final long maxSearch = this.npaths < this.offsets.size()
+                && this.npaths != 0 ? this.npaths : this.offsets.size();
         for (long i = 0; i < maxSearch; ++i) {
             final AddPathBestPath newBest = selectBest(localAs, keyList);
             newBestPathList.add(newBest);
index 29eed92f9d81c0795030e34d8edf7838093c4951..6b9f5dbf491ea07ea7be12c81f2f16bdb81250a8 100644 (file)
@@ -12,10 +12,10 @@ import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
 import org.opendaylight.protocol.bgp.mode.api.RouteEntry;
 
 public class AddPathBestNPathSelection implements PathSelectionMode {
-    private final Long nBestPaths;
+    private final Long npaths;
 
-    public AddPathBestNPathSelection(final Long nBestPaths) {
-        this.nBestPaths = nBestPaths;
+    public AddPathBestNPathSelection(final Long npaths) {
+        this.npaths = npaths;
     }
 
     @Override
@@ -29,6 +29,6 @@ public class AddPathBestNPathSelection implements PathSelectionMode {
     }
 
     public Long getNBestPaths() {
-        return this.nBestPaths;
+        return this.npaths;
     }
 }
\ No newline at end of file
index 3d7b7abf4f4fdd239d54a1d6d3647143745d63a8..747496abd30e3d8a89bfe100064d127d757dd65e 100644 (file)
@@ -22,8 +22,8 @@ final class ComplexRouteEntry extends AbstractNPathsRouteEntry {
     private static final MapEntryNode[] EMPTY_VALUES = new MapEntryNode[0];
     private MapEntryNode[] values = EMPTY_VALUES;
 
-    public ComplexRouteEntry(final Long nBestPaths) {
-        super(nBestPaths);
+    ComplexRouteEntry(final Long npaths) {
+        super(npaths);
     }
 
     @Override
@@ -43,7 +43,8 @@ final class ComplexRouteEntry extends AbstractNPathsRouteEntry {
     }
 
     @Override
-    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
+    public int addRoute(final UnsignedInteger routerId, final Long remotePathId,
+            final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
         final OffsetMap oldMap = getOffsets();
         final int offset = addRoute(new RouteKey(routerId, remotePathId), attributesIdentifier, data);
         final OffsetMap newMap = getOffsets();
index b9107240db4b8a60eb101d033d6f7152b848f586..673baa487516bc9714a47a9e8068880c125d2cf2 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 final class SimpleRouteEntry extends AbstractNPathsRouteEntry {
-    public SimpleRouteEntry(final Long nBestPaths) {
-        super(nBestPaths);
+    SimpleRouteEntry(final Long npaths) {
+        super(npaths);
     }
 
     @Override
@@ -33,7 +33,8 @@ final class SimpleRouteEntry extends AbstractNPathsRouteEntry {
     }
 
     @Override
-    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
+    public int addRoute(final UnsignedInteger routerId, final Long remotePathId,
+            final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
         return addRoute(new RouteKey(routerId, remotePathId), attributesIdentifier, data);
     }
 }
\ No newline at end of file
index 088fa60faf08748758ed706793c82774a77cc2ad..12aa4a60a2032bad51e7f72b32d6b0bc596f6646 100644 (file)
@@ -37,26 +37,11 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
     private BaseBestPath bestPath;
     private BaseBestPath removedBestPath;
 
-    private int addRoute(final UnsignedInteger routerId, final ContainerNode attributes) {
-        int offset = this.offsets.offsetOf(routerId);
-        if (offset < 0) {
-            final OffsetMap newOffsets = this.offsets.with(routerId);
-            offset = newOffsets.offsetOf(routerId);
-
-            this.values = newOffsets.expand(this.offsets, this.values, offset);
-            this.offsets = newOffsets;
-        }
-
-        this.offsets.setValue(this.values, offset, attributes);
-        LOG.trace("Added route from {} attributes {}", routerId, attributes);
-        return offset;
-    }
-
     /**
-     * Remove route
+     * Remove route.
      *
      * @param routerId router ID in unsigned integer
-     * @param offset of removed route
+     * @param offset   of removed route
      * @return true if its the last route
      */
     protected final boolean removeRoute(final UnsignedInteger routerId, final int offset) {
@@ -84,7 +69,7 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
         final BaseBestPath newBestPath = selector.result();
         final boolean modified = newBestPath == null || !newBestPath.equals(this.bestPath);
         if (modified) {
-            if(this.offsets.isEmpty()) {
+            if (this.offsets.isEmpty()) {
                 this.removedBestPath = this.bestPath;
             }
             LOG.trace("Previous best {}, current best {}", this.bestPath, newBestPath);
@@ -94,15 +79,29 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
     }
 
     @Override
-    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
+    public int addRoute(final UnsignedInteger routerId, final Long remotePathId,
+            final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
         LOG.trace("Find {} in {}", attributesIdentifier, data);
-        final ContainerNode advertisedAttrs = (ContainerNode) NormalizedNodes.findNode(data, attributesIdentifier).orNull();
-        return addRoute(routerId, advertisedAttrs);
+        final ContainerNode advertisedAttrs = (ContainerNode) NormalizedNodes
+                .findNode(data, attributesIdentifier).orNull();
+        int offset = this.offsets.offsetOf(routerId);
+        if (offset < 0) {
+            final OffsetMap newOffsets = this.offsets.with(routerId);
+            offset = newOffsets.offsetOf(routerId);
+
+            this.values = newOffsets.expand(this.offsets, this.values, offset);
+            this.offsets = newOffsets;
+        }
+
+        this.offsets.setValue(this.values, offset, advertisedAttrs);
+        LOG.trace("Added route from {} attributes {}", routerId, advertisedAttrs);
+        return offset;
     }
 
     @Override
-    public void updateRoute(final TablesKey localTK, final ExportPolicyPeerTracker peerPT, final YangInstanceIdentifier locRibTarget, final RIBSupport ribSup,
-        final DOMDataWriteTransaction tx, final PathArgument routeIdPA) {
+    public void updateRoute(final TablesKey localTK, final ExportPolicyPeerTracker peerPT,
+            final YangInstanceIdentifier locRibTarget, final RIBSupport ribSup,
+            final DOMDataWriteTransaction tx, final PathArgument routeIdPA) {
         if (this.removedBestPath != null) {
             removePathFromDataStore(this.removedBestPath, routeIdPA, locRibTarget, peerPT, localTK, ribSup, tx);
             this.removedBestPath = null;
@@ -113,21 +112,24 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
     }
 
     @Override
-    public void writeRoute(final PeerId destPeer, final PathArgument routeId, final YangInstanceIdentifier rootPath, final PeerExportGroup peerGroup,
-        final TablesKey localTK, final ExportPolicyPeerTracker peerPT, final RIBSupport ribSupport, final DOMDataWriteTransaction tx) {
+    public void writeRoute(final PeerId destPeer, final PathArgument routeId, final YangInstanceIdentifier rootPath,
+            final PeerExportGroup peerGroup, final TablesKey localTK, final ExportPolicyPeerTracker peerPT,
+            final RIBSupport ribSupport, final DOMDataWriteTransaction tx) {
         if (this.bestPath != null) {
             final BaseBestPath path = this.bestPath;
             final PeerRole destPeerRole = getRoutePeerIdRole(peerPT, destPeer);
             if (filterRoutes(path.getPeerId(), destPeer, peerPT, localTK, destPeerRole)) {
-                final ContainerNode effAttrib = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT,path.getPeerId()), path.getAttributes());
+                final ContainerNode effAttrib = peerGroup.effectiveAttributes(
+                        getRoutePeerIdRole(peerPT, path.getPeerId()), path.getAttributes());
                 writeRoute(destPeer, getAdjRibOutYII(ribSupport, rootPath, routeId, localTK), effAttrib,
-                    createValue(routeId, path), ribSupport, tx);
+                        createValue(routeId, path), ribSupport, tx);
             }
         }
     }
 
-    private void removePathFromDataStore(final BestPath path, final PathArgument routeIdPA, final YangInstanceIdentifier locRibTarget,
-        final ExportPolicyPeerTracker peerPT, final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
+    private void removePathFromDataStore(final BestPath path, final PathArgument routeIdPA,
+            final YangInstanceIdentifier locRibTarget, final ExportPolicyPeerTracker peerPT,
+            final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
         LOG.trace("Best Path removed {}", path);
         final PathArgument routeIdAddPath = ribSup.getRouteIdAddPath(path.getPathId(), routeIdPA);
         final YangInstanceIdentifier pathTarget = ribSup.routePath(locRibTarget.node(ROUTES_IDENTIFIER), routeIdPA);
@@ -139,8 +141,9 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
         fillAdjRibsOut(null, null, routeIdPA, path.getPeerId(), peerPT, localTK, ribSup, tx);
     }
 
-    private void addPathToDataStore(final BestPath path, final PathArgument routeIdPA, final YangInstanceIdentifier locRibTarget,
-        final RIBSupport ribSup, final ExportPolicyPeerTracker peerPT, final TablesKey localTK, final DOMDataWriteTransaction tx) {
+    private void addPathToDataStore(final BestPath path, final PathArgument routeIdPA,
+            final YangInstanceIdentifier locRibTarget, final RIBSupport ribSup, final ExportPolicyPeerTracker peerPT,
+            final TablesKey localTK, final DOMDataWriteTransaction tx) {
         final PathArgument routeIdAddPath = ribSup.getRouteIdAddPath(path.getPathId(), routeIdPA);
         final YangInstanceIdentifier pathTarget = ribSup.routePath(locRibTarget.node(ROUTES_IDENTIFIER), routeIdPA);
         final NormalizedNode<?, ?> value = createValue(routeIdPA, path);
@@ -153,7 +156,8 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
             addPathValue = createValue(routeIdAddPath, path);
             LOG.trace("Selected best value {}", addPathValue);
         }
-        fillLocRib(pathAddPathTarget == null ? pathTarget : pathAddPathTarget, addPathValue == null ? value : addPathValue, tx);
+        fillLocRib(pathAddPathTarget == null ? pathTarget : pathAddPathTarget,
+                addPathValue == null ? value : addPathValue, tx);
         fillAdjRibsOut(path.getAttributes(), value, routeIdPA, path.getPeerId(), peerPT, localTK, ribSup, tx);
     }
 
@@ -163,8 +167,8 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
 
     @VisibleForTesting
     private void fillAdjRibsOut(final ContainerNode attributes, final NormalizedNode<?, ?> value,
-        final PathArgument routeId, final PeerId routePeerId, final ExportPolicyPeerTracker peerPT,
-        final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
+            final PathArgument routeId, final PeerId routePeerId, final ExportPolicyPeerTracker peerPT,
+            final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
         /*
          * We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
          * expose from which client a particular route was learned from in the local RIB, and have
@@ -178,7 +182,7 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry {
             final PeerExportGroup peerGroup = peerPT.getPeerGroup(role);
             if (peerGroup != null) {
                 final ContainerNode effAttrib = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT, routePeerId),
-                    attributes);
+                        attributes);
                 peerGroup.forEach((destPeer, rootPath) -> {
                     if (!filterRoutes(routePeerId, destPeer, peerPT, localTK, getRoutePeerIdRole(peerPT, destPeer))) {
                         return;
index 04c22444aafc9c2ec0e8450a2e4715e32e3467a2..4195a5c6e12f4d295dbf9baa99ed15a7446e7467 100644 (file)
@@ -20,7 +20,8 @@ final class BaseComplexRouteEntry extends BaseAbstractRouteEntry {
     private MapEntryNode[] values = EMPTY_VALUES;
 
     @Override
-    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attrII, final NormalizedNode<?, ?> data) {
+    public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attrII,
+            final NormalizedNode<?, ?> data) {
         final OffsetMap oldMap = getOffsets();
         final int offset = super.addRoute(routerId, remotePathId, attrII, data);
         final OffsetMap newMap = getOffsets();
index a07a0c29a13556fc11705281979a50261e071c6d..6ae03377b7e492087879cd1bac896b2d48883bf7 100644 (file)
@@ -31,18 +31,18 @@ import org.slf4j.LoggerFactory;
  * array members and array management features.
  */
 final class OffsetMap {
-    static final OffsetMap EMPTY = new OffsetMap(Collections.emptySet());
     private static final Logger LOG = LoggerFactory.getLogger(OffsetMap.class);
     private static final String NEGATIVEOFFSET = "Invalid negative offset %s";
     private static final String INVALIDOFFSET = "Invalid offset %s for %s router IDs";
-    private static final LoadingCache<Set<UnsignedInteger>, OffsetMap> OFFSETMAPS = CacheBuilder.newBuilder().weakValues().build(
-        new CacheLoader<Set<UnsignedInteger>, OffsetMap>() {
-            @Override
-            public OffsetMap load(@Nonnull final Set<UnsignedInteger> key) throws Exception {
-                return new OffsetMap(key);
-            }
-        });
+    private static final LoadingCache<Set<UnsignedInteger>, OffsetMap> OFFSETMAPS = CacheBuilder.newBuilder()
+            .weakValues().build(new CacheLoader<Set<UnsignedInteger>, OffsetMap>() {
+                @Override
+                public OffsetMap load(@Nonnull final Set<UnsignedInteger> key) {
+                    return new OffsetMap(key);
+                }
+            });
     private static final Comparator<UnsignedInteger> COMPARATOR = UnsignedInteger::compareTo;
+    static final OffsetMap EMPTY = new OffsetMap(Collections.emptySet());
     private final UnsignedInteger[] routeKeys;
 
     private OffsetMap(final Set<UnsignedInteger> routerIds) {
index b6018024448c671df1e0c38b46af64c5d4cf34bc..42fc10d46080e01567ac18a2ca420c13bd0ed613 100644 (file)
@@ -23,7 +23,7 @@ public abstract class AbstractBestPath implements BestPath {
         this.state = requireNonNull(state);
     }
 
-    protected abstract MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper);
+    protected abstract MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper);
 
     @VisibleForTesting
     public final BestPathState getState() {
index 03dc3dc8db4547fc064b00de0211cc8d62705e15..05fae4d2d3e238020a9e9d1ff684bda96837b4b4 100644 (file)
@@ -25,7 +25,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 
 public class AbstractBestPathSelector {
     private static final Collection<YangInstanceIdentifier.PathArgument> ORIGINATOR_ID = ImmutableList.of(new
-        YangInstanceIdentifier.NodeIdentifier(OriginatorId.QNAME), new YangInstanceIdentifier.NodeIdentifier(QName.create(OriginatorId.QNAME, "originator")));
+        YangInstanceIdentifier.NodeIdentifier(OriginatorId.QNAME),
+            new YangInstanceIdentifier.NodeIdentifier(QName.create(OriginatorId.QNAME, "originator")));
 
     private final Long ourAs;
     protected UnsignedInteger bestOriginatorId = null;
index 87428f01e0fd19f7c03221418557d9f0bf6c25fe..ec58b69229d0d3310a86c466d3214341121d7dae 100644 (file)
@@ -72,10 +72,12 @@ public abstract class AbstractRouteEntry implements RouteEntry {
 
     protected static boolean filterRoutes(final PeerId rootPeer, final PeerId destPeer,
             final ExportPolicyPeerTracker peerPT, final TablesKey localTK, final PeerRole destPeerRole) {
-        return !rootPeer.equals(destPeer) && isTableSupportedAndReady(destPeer, peerPT, localTK) && !PeerRole.Internal.equals(destPeerRole);
+        return !rootPeer.equals(destPeer) && isTableSupportedAndReady(destPeer, peerPT, localTK)
+                && !PeerRole.Internal.equals(destPeerRole);
     }
 
-    private static boolean isTableSupportedAndReady(final PeerId destPeer, final ExportPolicyPeerTracker peerPT, final TablesKey localTK) {
+    private static boolean isTableSupportedAndReady(final PeerId destPeer, final ExportPolicyPeerTracker peerPT,
+            final TablesKey localTK) {
         if (!peerPT.isTableSupported(destPeer) || !peerPT.isTableStructureInitialized(destPeer)) {
             LOG.trace("Route rejected, peer {} does not support this table type {}", destPeer, localTK);
             return false;
@@ -85,8 +87,8 @@ public abstract class AbstractRouteEntry implements RouteEntry {
 
     protected static YangInstanceIdentifier getAdjRibOutYII(final RIBSupport ribSup,
             final YangInstanceIdentifier rootPath, final PathArgument routeId, final TablesKey localTK) {
-        return ribSup.routePath(rootPath.node(AdjRibOut.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(localTK))
-            .node(ROUTES_IDENTIFIER), routeId);
+        return ribSup.routePath(rootPath.node(AdjRibOut.QNAME).node(Tables.QNAME)
+                .node(RibSupportUtils.toYangTablesKey(localTK)).node(ROUTES_IDENTIFIER), routeId);
     }
 
     protected PeerRole getRoutePeerIdRole(final ExportPolicyPeerTracker peerPT, final PeerId routePeerId) {
index 1e40ed1cfed539e86fcc6a6f88983779347d215d..2753d9d6e25c9602723bee48bfb051ccd27c6946 100644 (file)
@@ -27,8 +27,10 @@ public final class RouteEntryUtil {
         return b.build();
     }
 
-    public static MapEntryNode createComplexRouteValue(final PathArgument routeId, final BestPath path, final MapEntryNode mapValues) {
-        final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = Builders.mapEntryBuilder();
+    public static MapEntryNode createComplexRouteValue(final PathArgument routeId, final BestPath path,
+            final MapEntryNode mapValues) {
+        final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder
+                = Builders.mapEntryBuilder();
         mapEntryBuilder.withNodeIdentifier((NodeIdentifierWithPredicates) routeId);
         mapEntryBuilder.addChild(path.getAttributes());
         mapValues.getValue().forEach(mapEntryBuilder::addChild);
index 20965c1d07fe66aa44b60dc939263ebb794e48b1..d128436e93303df5e0b1fc543df68065b66c8e07 100644 (file)
@@ -23,6 +23,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -62,28 +64,43 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo
 public abstract class AbstractRouteEntryTest {
     protected static final long REMOTE_PATH_ID = 1;
     protected static final PeerId PEER_ID = new PeerId("bgp://42.42.42.42");
-    protected static final YangInstanceIdentifier PEER_YII2 = YangInstanceIdentifier.of(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet:test", "2015-03-05", "peer2"));
+    protected static final YangInstanceIdentifier PEER_YII2 = YangInstanceIdentifier
+            .of(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet:test",
+                    "2015-03-05", "peer2"));
     protected static final long AS = 64444;
     protected static final UnsignedInteger ROUTER_ID = UnsignedInteger.ONE;
-    protected static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
-    protected static final YangInstanceIdentifier LOC_RIB_TARGET = YangInstanceIdentifier.create(YangInstanceIdentifier.of(BgpRib.QNAME)
-        .node(LocRib.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).getPathArguments());
+    protected static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class,
+            UnicastSubsequentAddressFamily.class);
+    protected static final YangInstanceIdentifier LOC_RIB_TARGET =
+            YangInstanceIdentifier.create(YangInstanceIdentifier.of(BgpRib.QNAME).node(LocRib.QNAME)
+                    .node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).getPathArguments());
     private static final long PATH_ID = 1;
     private static final PeerId PEER_ID2 = new PeerId("bgp://43.43.43.43");
     private static final String PREFIX = "1.2.3.4/32";
     private static final String PREFIX2 = "2.2.2.2/32";
-    private static final YangInstanceIdentifier PEER_YII = YangInstanceIdentifier.of(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet:test", "2015-03-05", "peer1"));
+    private static final YangInstanceIdentifier PEER_YII
+            = YangInstanceIdentifier.of(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet:test",
+            "2015-03-05", "peer1"));
     private static final NodeIdentifier ROUTES_IDENTIFIER = new NodeIdentifier(Routes.QNAME);
-    private static final NodeIdentifier ORIGIN_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, Origin.QNAME.getLocalName()).intern());
-    private static final NodeIdentifier ORIGIN_VALUE_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, "value").intern());
-    private static final NodeIdentifier AS_PATH_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, AsPath.QNAME.getLocalName()).intern());
-    private static final NodeIdentifier ATOMIC_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, AtomicAggregate.QNAME.getLocalName()));
+    private static final NodeIdentifier ORIGIN_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            Origin.QNAME.getLocalName()).intern());
+    private static final NodeIdentifier ORIGIN_VALUE_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            "value").intern());
+    private static final NodeIdentifier AS_PATH_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            AsPath.QNAME.getLocalName()).intern());
+    private static final NodeIdentifier ATOMIC_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            AtomicAggregate.QNAME.getLocalName()));
     private static final QName Q_NAME = BindingReflections.findQName(Ipv4Routes.class).intern();
-    private static final NodeIdentifier ROUTE_ATTRIBUTES_IDENTIFIER = new NodeIdentifier(QName.create(Q_NAME, Attributes.QNAME.getLocalName().intern()));
-    private static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
-    protected static final NodeIdentifierWithPredicates ROUTE_ID_PA = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, ImmutableMap.of(PREFIX_QNAME, PREFIX));
+    private static final NodeIdentifier ROUTE_ATTRIBUTES_IDENTIFIER
+            = new NodeIdentifier(QName.create(Q_NAME, Attributes.QNAME.getLocalName().intern()));
+    private static final QName PREFIX_QNAME
+            = QName.create(Ipv4Route.QNAME, "prefix").intern();
+    protected static final NodeIdentifierWithPredicates ROUTE_ID_PA
+            = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, ImmutableMap.of(PREFIX_QNAME, PREFIX));
     private static final QName PATHID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
-    protected static final NodeIdentifierWithPredicates ROUTE_ID_PA_ADD_PATH = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, ImmutableMap.of(PATHID_QNAME, PATH_ID, PREFIX_QNAME, PREFIX2));
+    protected static final NodeIdentifierWithPredicates ROUTE_ID_PA_ADD_PATH
+            = new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
+            ImmutableMap.of(PATHID_QNAME, PATH_ID, PREFIX_QNAME, PREFIX2));
     @Mock
     protected RIBSupport ribSupport;
     @Mock
@@ -92,7 +109,7 @@ public abstract class AbstractRouteEntryTest {
     protected ExportPolicyPeerTracker peerPT;
     @Mock
     protected PeerExportGroup peg;
-    protected List<YangInstanceIdentifier> yIIChanges;
+    protected List<YangInstanceIdentifier> yiichanges;
     protected NormalizedNode<?, ?> attributes;
     protected YangInstanceIdentifier routePaYii;
     protected YangInstanceIdentifier routePaAddPathYii;
@@ -111,17 +128,19 @@ public abstract class AbstractRouteEntryTest {
 
     protected void setUp() {
         MockitoAnnotations.initMocks(this);
-        this.yIIChanges = new ArrayList<>();
+        this.yiichanges = new ArrayList<>();
         this.attributes = createAttr();
         this.locRibTargetYii = LOC_RIB_TARGET.node(ROUTES_IDENTIFIER);
-        this.locRibOutTargetYii = PEER_YII.node(AdjRibOut.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).node(ROUTES_IDENTIFIER);
+        this.locRibOutTargetYii = PEER_YII.node(AdjRibOut.QNAME).node(Tables.QNAME)
+                .node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).node(ROUTES_IDENTIFIER);
         this.routePaYii = this.locRibTargetYii.node(ROUTE_ID_PA);
         this.routePaAddPathYii = this.locRibTargetYii.node(ROUTE_ID_PA_ADD_PATH);
         this.routeRiboutYii = this.locRibOutTargetYii.node(ROUTE_ID_PA);
         this.routeAddRiboutYii = this.locRibOutTargetYii.node(ROUTE_ID_PA_ADD_PATH);
         this.routeRiboutAttYii = this.locRibOutTargetYii.node(ROUTE_ID_PA).node(ATTRS_EXTENSION_Q);
         this.routeAddRiboutAttYii = this.locRibOutTargetYii.node(ROUTE_ID_PA_ADD_PATH).node(ATTRS_EXTENSION_Q);
-        this.locRibOutTargetYiiPeer2 = PEER_YII2.node(AdjRibOut.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).node(ROUTES_IDENTIFIER);
+        this.locRibOutTargetYiiPeer2 = PEER_YII2.node(AdjRibOut.QNAME).node(Tables.QNAME)
+                .node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).node(ROUTES_IDENTIFIER);
         this.routeRiboutYiiPeer2 = this.locRibOutTargetYiiPeer2.node(ROUTE_ID_PA);
         this.routeRiboutAttYiiPeer2 = this.locRibOutTargetYiiPeer2.node(ROUTE_ID_PA).node(ATTRS_EXTENSION_Q);
         this.routeAddRiboutYiiPeer2 = this.locRibOutTargetYiiPeer2.node(ROUTE_ID_PA_ADD_PATH);
@@ -134,22 +153,23 @@ public abstract class AbstractRouteEntryTest {
     private void mockTransactionChain() {
         doAnswer(invocation -> {
             final Object[] args = invocation.getArguments();
-            this.yIIChanges.add((YangInstanceIdentifier) args[1]);
+            this.yiichanges.add((YangInstanceIdentifier) args[1]);
             return args[1];
-        }).when(this.tx).put(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
+        }).when(this.tx)
+                .put(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
 
         doAnswer(invocation -> {
             final Object[] args = invocation.getArguments();
             if (this.routePaYii.equals(args[1])) {
-                this.yIIChanges.remove(this.routePaYii);
+                this.yiichanges.remove(this.routePaYii);
             } else if (this.routePaAddPathYii.equals(args[1])) {
-                this.yIIChanges.remove(this.routePaAddPathYii);
+                this.yiichanges.remove(this.routePaAddPathYii);
             } else if (this.routeRiboutYii.equals(args[1])) {
-                this.yIIChanges.remove(this.routeRiboutYii);
-                this.yIIChanges.remove(this.routeAddRiboutAttYii);
+                this.yiichanges.remove(this.routeRiboutYii);
+                this.yiichanges.remove(this.routeAddRiboutAttYii);
             } else if (this.routeAddRiboutYii.equals(args[1])) {
-                this.yIIChanges.remove(this.routeAddRiboutYii);
-                this.yIIChanges.remove(this.routeAddRiboutAttYii);
+                this.yiichanges.remove(this.routeAddRiboutYii);
+                this.yiichanges.remove(this.routeAddRiboutAttYii);
             }
             return args[1];
         }).when(this.tx).delete(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
@@ -201,7 +221,8 @@ public abstract class AbstractRouteEntryTest {
 
     private void mockRibSupport() {
         doReturn(ROUTE_ATTRIBUTES_IDENTIFIER).when(this.ribSupport).routeAttributesIdentifier();
-        doReturn(ROUTE_ID_PA_ADD_PATH).when(this.ribSupport).getRouteIdAddPath(any(Long.class), eq(ROUTE_ID_PA_ADD_PATH));
+        doReturn(ROUTE_ID_PA_ADD_PATH).when(this.ribSupport)
+                .getRouteIdAddPath(any(Long.class), eq(ROUTE_ID_PA_ADD_PATH));
         doReturn(null).when(this.ribSupport).getRouteIdAddPath(any(Long.class), eq(ROUTE_ID_PA));
         doAnswer(invocation -> {
             final Object[] args = invocation.getArguments();
@@ -230,13 +251,19 @@ public abstract class AbstractRouteEntryTest {
     }
 
     private static NormalizedNode<?, ?> createAttr() {
-        final ContainerNode attributes = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ATTRS_EXTENSION_Q))
+        final ContainerNode attributes = Builders.containerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(ATTRS_EXTENSION_Q))
             .addChild(Builders.containerBuilder().withNodeIdentifier(ORIGIN_NID)
-                .addChild(Builders.leafBuilder().withNodeIdentifier(ORIGIN_VALUE_NID).withValue("igp").build()).build())
+                .addChild(Builders.leafBuilder().withNodeIdentifier(ORIGIN_VALUE_NID)
+                        .withValue("igp").build()).build())
             .addChild(Builders.containerBuilder().withNodeIdentifier(AS_PATH_NID)
                 .addChild(Builders.unkeyedListBuilder().withNodeIdentifier(SEGMENTS_NID).build()).build())
             .addChild(Builders.containerBuilder().withNodeIdentifier(ATOMIC_NID).build()).build();
         return ImmutableContainerNodeBuilder.create().withNodeIdentifier(ROUTE_ATTRIBUTES_IDENTIFIER)
             .withChild(attributes).build();
     }
+
+    protected Map<YangInstanceIdentifier, Long> collectInfo() {
+        return this.yiichanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+    }
 }
index 1680f268bbeae1830fa0c0a308eb226fbb6243f7..4f8f4af71c5d8262fc4e8340527538fc12587053 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.mode.impl.AbstractRouteEntryTest;
@@ -35,12 +33,14 @@ public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
     }
 
     private void testAddRouteSelectBestAndWriteOnDS() {
-        this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(), this.attributes);
+        this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport
+                .routeAttributesIdentifier(), this.attributes);
         assertFalse(this.testBARE.isEmpty());
         assertTrue(this.testBARE.selectBest(AS));
         /** Add AddPath Route **/
-        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA_ADD_PATH);
-        Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport,
+                this.tx, ROUTE_ID_PA_ADD_PATH);
+        final Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(3, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
         assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
@@ -48,13 +48,14 @@ public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
     }
 
     private void testRemoveRoute() {
-        Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(3, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
         assertTrue(this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID));
         assertTrue(this.testBARE.selectBest(AS));
-        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA_ADD_PATH);
-        yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport,
+                this.tx, ROUTE_ID_PA_ADD_PATH);
+        yiiCount = collectInfo();
         assertEquals(0, yiiCount.size());
         assertFalse(yiiCount.containsKey(this.routePaAddPathYii));
         assertFalse(yiiCount.containsKey(this.routeAddRiboutYii));
index 8a9892e2b8cd3b00a6c6ab25ea1c341aadaaef6f..e941a17dd91d9b7494e860dba130f5d0a343ca77 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.mode.impl.AbstractRouteEntryTest;
@@ -45,17 +43,20 @@ public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
     }
 
     private void testWriteEmptyBestPath() {
-        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport, this.tx);
-        assertEquals(0, this.yIIChanges.size());
+        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport,
+                this.tx);
+        assertEquals(0, this.yiichanges.size());
     }
 
     private void testAddRouteSelectBestAndWriteOnDS() {
-        this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(), this.attributes);
+        this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(),
+                this.attributes);
         assertFalse(this.testBARE.isEmpty());
         assertTrue(this.testBARE.selectBest(AS));
         /** Add AddPath Route **/
-        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA_ADD_PATH);
-        Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx,
+                ROUTE_ID_PA_ADD_PATH);
+        final Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(3, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
         assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
@@ -68,23 +69,24 @@ public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
     }
 
     private void testInitializePeerWithExistentRoute() {
-        assertEquals(3, this.yIIChanges.size());
-        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA_ADD_PATH, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport, this.tx);
-        assertEquals(5, this.yIIChanges.size());
-        final Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream()
-            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        assertEquals(3, this.yiichanges.size());
+        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA_ADD_PATH, PEER_YII2, this.peg, TABLES_KEY, this.peerPT,
+                this.ribSupport, this.tx);
+        assertEquals(5, this.yiichanges.size());
+        final Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYiiPeer2));
         assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYiiPeer2));
     }
 
     private void testRemoveRoute() {
-        Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(5, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
         assertTrue(this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID));
         assertTrue(this.testBARE.selectBest(AS));
-        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA_ADD_PATH);
-        yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx,
+                ROUTE_ID_PA_ADD_PATH);
+        yiiCount = collectInfo();
         assertEquals(2, yiiCount.size());
         assertFalse(yiiCount.containsKey(this.routePaAddPathYii));
         assertFalse(yiiCount.containsKey(this.routeAddRiboutYii));
index 5a209239fc1ff5e6390f33f0159719da69daea79..878f84d2ce855eeb3871e350675057d22a794c54 100644 (file)
@@ -26,7 +26,8 @@ public class BaseBestPathTest {
     @Before
     public void setUp() throws Exception {
         final BasePathSelector selector = new BasePathSelector(20L);
-        selector.processPath(BasePathSelectorTest.ROUTER_ID2, BasePathSelectorTest.createStateFromPrefMedOriginASPath().build());
+        selector.processPath(BasePathSelectorTest.ROUTER_ID2,
+                BasePathSelectorTest.createStateFromPrefMedOriginASPath().build());
         this.baseBestPath = selector.result();
         this.baseBestPathCopy = selector.result();
     }
@@ -48,7 +49,8 @@ public class BaseBestPathTest {
 
     @Test
     public void testHashCodeAndEqual() throws Exception {
-        assertTrue(this.baseBestPath.equals(this.baseBestPathCopy) && this.baseBestPathCopy.equals(this.baseBestPath));
+        assertTrue(this.baseBestPath.equals(this.baseBestPathCopy)
+                && this.baseBestPathCopy.equals(this.baseBestPath));
         assertTrue(this.baseBestPath.hashCode() == this.baseBestPathCopy.hashCode());
         assertTrue(this.baseBestPath.getPathId() == PATH_ID);
     }
index 6f6f955f5b41a05579d209c89aa09338f88b67e3..c17ede0b8911e037fb83c755397079d034d40ab1 100644 (file)
@@ -38,38 +38,52 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUn
 
 public class BasePathSelectorTest {
 
-    public static final QName ATTRS_EXTENSION_Q = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet", "2017-12-07", "attributes");
+    public static final QName ATTRS_EXTENSION_Q = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
+            "2017-12-07", "attributes");
     public static final QName AS_NUMBER_Q = QName.create(ATTRS_EXTENSION_Q, "as-number");
-    public static final NodeIdentifier SEGMENTS_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, Segments.QNAME.getLocalName()));
-    public static final NodeIdentifier SEQ_LEAFLIST_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, "as-sequence"));
-    public static final UnkeyedListEntryNode SEQ_SEGMENT = Builders.unkeyedListEntryBuilder().withNodeIdentifier(SEGMENTS_NID)
-        .addChild(Builders.orderedLeafSetBuilder().withNodeIdentifier(SEQ_LEAFLIST_NID)
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 1L)).withValue(1L).build())
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 2L)).withValue(2L).build())
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 3L)).withValue(3L).build())
-            .build()).build();
-    private static final NodeIdentifier SET_LEAFLIST_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, "as-set"));
-    public static final UnkeyedListEntryNode SET_SEGMENT = Builders.unkeyedListEntryBuilder().withNodeIdentifier(SEGMENTS_NID)
-        .addChild(Builders.leafSetBuilder().withNodeIdentifier(SET_LEAFLIST_NID)
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 10L)).withValue(10L).build())
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 11L)).withValue(11L).build())
-            .build()).build();
-    private static final UnkeyedListEntryNode SEQ_SEGMENT2 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(SEGMENTS_NID)
-        .addChild(Builders.orderedLeafSetBuilder().withNodeIdentifier(SEQ_LEAFLIST_NID)
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 20L)).withValue(20L).build())
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 2L)).withValue(2L).build())
-            .addChild(Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 3L)).withValue(3L).build())
-            .build()).build();
+    public static final NodeIdentifier SEGMENTS_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            Segments.QNAME.getLocalName()));
+    public static final NodeIdentifier SEQ_LEAFLIST_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            "as-sequence"));
+    public static final UnkeyedListEntryNode SEQ_SEGMENT = Builders.unkeyedListEntryBuilder()
+            .withNodeIdentifier(SEGMENTS_NID).addChild(Builders.orderedLeafSetBuilder()
+                    .withNodeIdentifier(SEQ_LEAFLIST_NID)
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 1L)).withValue(1L).build())
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 2L)).withValue(2L).build())
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 3L)).withValue(3L).build())
+                    .build()).build();
+    private static final NodeIdentifier SET_LEAFLIST_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q,
+            "as-set"));
+    public static final UnkeyedListEntryNode SET_SEGMENT = Builders.unkeyedListEntryBuilder()
+            .withNodeIdentifier(SEGMENTS_NID).addChild(Builders.leafSetBuilder().withNodeIdentifier(SET_LEAFLIST_NID)
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 10L)).withValue(10L).build())
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 11L)).withValue(11L).build())
+                    .build()).build();
+    private static final UnkeyedListEntryNode SEQ_SEGMENT2 = Builders.unkeyedListEntryBuilder()
+            .withNodeIdentifier(SEGMENTS_NID).addChild(Builders.orderedLeafSetBuilder()
+                    .withNodeIdentifier(SEQ_LEAFLIST_NID)
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 20L)).withValue(20L).build())
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 2L)).withValue(2L).build())
+                    .addChild(Builders.leafSetEntryBuilder()
+                            .withNodeIdentifier(new NodeWithValue<>(AS_NUMBER_Q, 3L)).withValue(3L).build())
+                    .build()).build();
     private static final QName LOCAL_PREF_Q_NAME = QName.create(ATTRS_EXTENSION_Q, "local-pref");
     private static final QName MULTI_EXIT_DISC_Q_NAME = QName.create(ATTRS_EXTENSION_Q, "multi-exit-disc");
     private static final QName ORIGIN_Q_NAME = QName.create(ATTRS_EXTENSION_Q, "origin");
     private static final QName AS_PATH_Q_NAME = QName.create(ATTRS_EXTENSION_Q, "as-path");
-    private final UnsignedInteger ROUTER_ID = RouterIds.routerIdForAddress("127.0.0.1");
+    private static final UnsignedInteger ROUTER_ID = RouterIds.routerIdForAddress("127.0.0.1");
     static final UnsignedInteger ROUTER_ID2 = RouterIds.routerIdForPeerId(new PeerId("bgp://127.0.0.1"));
-    private final UnsignedInteger ROUTER_ID3 = RouterIds.routerIdForPeerId(new PeerId("bgp://127.0.0.2"));
+    private static final UnsignedInteger ROUTER_ID3 = RouterIds.routerIdForPeerId(new PeerId("bgp://127.0.0.2"));
     private final BasePathSelector selector = new BasePathSelector(20L);
     private final BestPathStateImpl state = new BestPathStateImpl(createStateFromPrefMedOriginASPath().build());
-    private final BaseBestPath originBestPath = new BaseBestPath(this.ROUTER_ID, this.state);
+    private final BaseBestPath originBestPath = new BaseBestPath(ROUTER_ID, this.state);
 
     @Test
     public void testBestPathForEquality() {
@@ -86,7 +100,6 @@ public class BasePathSelectorTest {
 
     @Test
     public void testBestPathWithHigherLocalPref() {
-        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder = createContBuilder(ATTRS_EXTENSION_Q);
         this.selector.processPath(ROUTER_ID2, createStateFromPrefMedOrigin());   // local-pref 123
         BaseBestPath processedPath = this.selector.result();
         assertEquals(123L, processedPath.getState().getLocalPref().longValue());
@@ -95,6 +108,8 @@ public class BasePathSelectorTest {
         processedPath = this.selector.result();
         assertEquals(321L, processedPath.getState().getLocalPref().longValue());
 
+        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder =
+                createContBuilder(ATTRS_EXTENSION_Q);
         addLowerLocalRef(dataContBuilder); // prefer path with higher LOCAL_PREF
         this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
         processedPath = this.selector.result();
@@ -103,7 +118,8 @@ public class BasePathSelectorTest {
 
     @Test
     public void testBestPathSelectionOptions() {
-        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder = createStateFromPrefMedOriginASPath();
+        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder
+                = createStateFromPrefMedOriginASPath();
         this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
         BaseBestPath processedPath = this.selector.result();
         assertEquals(1, processedPath.getState().getOrigin().getIntValue());
@@ -143,7 +159,7 @@ public class BasePathSelectorTest {
 
     @Test
     public void testBestPathForNonEquality() {
-        this.selector.processPath(this.ROUTER_ID3, createStateFromPrefMedOrigin());
+        this.selector.processPath(ROUTER_ID3, createStateFromPrefMedOrigin());
         final BaseBestPath processedPath = this.selector.result();
 
         assertNotEquals(this.originBestPath.getPeerId(), processedPath.getPeerId());
@@ -155,7 +171,8 @@ public class BasePathSelectorTest {
     }
 
     private static ContainerNode createStateFromPrefMedOrigin() {
-        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder = createContBuilder(ATTRS_EXTENSION_Q);
+        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder
+                = createContBuilder(ATTRS_EXTENSION_Q);
         addLowerLocalRef(dataContBuilder);
         addLowerMultiExitDisc(dataContBuilder);
         addIgpOrigin(dataContBuilder);
@@ -163,7 +180,8 @@ public class BasePathSelectorTest {
     }
 
     static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createStateFromPrefMedOriginASPath() {
-        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder = createContBuilder(ATTRS_EXTENSION_Q);
+        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder
+                = createContBuilder(ATTRS_EXTENSION_Q);
         addHigherLocalRef(dataContBuilder);
         addHigherMultiExitDisc(dataContBuilder);
         addEgpOrigin(dataContBuilder);
@@ -171,35 +189,50 @@ public class BasePathSelectorTest {
         return dataContBuilder;
     }
 
-    private static void addLowerLocalRef(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
-        dataContBuilder.addChild(createContBuilder(LOCAL_PREF_Q_NAME).addChild(createValueBuilder(123L, LOCAL_PREF_Q_NAME, "pref").build()).build());
+    private static void addLowerLocalRef(
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
+        dataContBuilder.addChild(createContBuilder(LOCAL_PREF_Q_NAME)
+                .addChild(createValueBuilder(123L, LOCAL_PREF_Q_NAME, "pref").build()).build());
     }
 
-    private static void addHigherLocalRef(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
-        dataContBuilder.addChild(createContBuilder(LOCAL_PREF_Q_NAME).addChild(createValueBuilder(321L, LOCAL_PREF_Q_NAME, "pref").build()).build());
+    private static void addHigherLocalRef(
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
+        dataContBuilder.addChild(createContBuilder(LOCAL_PREF_Q_NAME)
+                .addChild(createValueBuilder(321L, LOCAL_PREF_Q_NAME, "pref").build()).build());
     }
 
-    private static void addLowerMultiExitDisc(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
-        dataContBuilder.addChild(createContBuilder(MULTI_EXIT_DISC_Q_NAME).addChild(createValueBuilder(1234L, MULTI_EXIT_DISC_Q_NAME, "med").build()).build());
+    private static void addLowerMultiExitDisc(
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
+        dataContBuilder.addChild(createContBuilder(MULTI_EXIT_DISC_Q_NAME)
+                .addChild(createValueBuilder(1234L, MULTI_EXIT_DISC_Q_NAME, "med").build()).build());
     }
 
-    private static void addHigherMultiExitDisc(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
-        dataContBuilder.addChild(createContBuilder(MULTI_EXIT_DISC_Q_NAME).addChild(createValueBuilder(4321L, MULTI_EXIT_DISC_Q_NAME, "med").build()).build());
+    private static void addHigherMultiExitDisc(
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
+        dataContBuilder.addChild(createContBuilder(MULTI_EXIT_DISC_Q_NAME)
+                .addChild(createValueBuilder(4321L, MULTI_EXIT_DISC_Q_NAME, "med").build()).build());
     }
 
-    private static void addIgpOrigin(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
-        dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME).addChild(createValueBuilder("igp", ORIGIN_Q_NAME, "value").build()).build());
+    private static void addIgpOrigin(
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
+        dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME)
+                .addChild(createValueBuilder("igp", ORIGIN_Q_NAME, "value").build()).build());
     }
 
-    private static void addEgpOrigin(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
-        dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME).addChild(createValueBuilder("egp", ORIGIN_Q_NAME, "value").build()).build());
+    private static void addEgpOrigin(
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder) {
+        dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME)
+                .addChild(createValueBuilder("egp", ORIGIN_Q_NAME, "value").build()).build());
     }
 
-    private static void addAsPath(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder, final UnkeyedListEntryNode segment) {
-        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> asPathContBuilder = ImmutableContainerNodeSchemaAwareBuilder.create();
+    private static void addAsPath(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder,
+            final UnkeyedListEntryNode segment) {
+        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> asPathContBuilder
+                = ImmutableContainerNodeSchemaAwareBuilder.create();
         asPathContBuilder.withNodeIdentifier(new NodeIdentifier(AS_PATH_Q_NAME));
 
-        final CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> segments = ImmutableUnkeyedListNodeBuilder.create();
+        final CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> segments
+                = ImmutableUnkeyedListNodeBuilder.create();
         segments.withNodeIdentifier(SEGMENTS_NID);
         segments.addChild(segment);
         asPathContBuilder.addChild(segments.build());
@@ -211,7 +244,8 @@ public class BasePathSelectorTest {
         return ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(new NodeIdentifier(qname));
     }
 
-    private static <T> ImmutableLeafNodeBuilder<T> createValueBuilder(final T value, final QName qname, final String localName) {
+    private static <T> ImmutableLeafNodeBuilder<T> createValueBuilder(final T value, final QName qname,
+            final String localName) {
         final ImmutableLeafNodeBuilder<T> valueBuilder = new ImmutableLeafNodeBuilder<>();
         valueBuilder.withNodeIdentifier(new NodeIdentifier(QName.create(qname, localName))).withValue(value);
         return valueBuilder;
@@ -231,7 +265,8 @@ public class BasePathSelectorTest {
         sequences.add(new AsNumber(2L));
         sequences.add(new AsNumber(3L));
         final List<Segments> expected = new ArrayList<>();
-        expected.add(new SegmentsBuilder().setAsSet(Lists.newArrayList(new AsNumber(11L), new AsNumber(10L))).build());
+        expected.add(new SegmentsBuilder()
+                .setAsSet(Lists.newArrayList(new AsNumber(11L), new AsNumber(10L))).build());
         expected.add(new SegmentsBuilder().setAsSequence(sequences).build());
         // test
         final List<Segments> actual = this.state.extractSegments(builder.build());
@@ -243,14 +278,18 @@ public class BasePathSelectorTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testBgpOrigin() {
-        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder = createContBuilder(ATTRS_EXTENSION_Q);
-        final ContainerNode containerIncom = dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME).addChild(createValueBuilder("incomplete", ORIGIN_Q_NAME, "value").build()).build()).build();
-        this.selector.processPath(this.ROUTER_ID3, containerIncom);
+        DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> dataContBuilder
+                = createContBuilder(ATTRS_EXTENSION_Q);
+        final ContainerNode containerIncom = dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME)
+                .addChild(createValueBuilder("incomplete", ORIGIN_Q_NAME, "value")
+                        .build()).build()).build();
+        this.selector.processPath(ROUTER_ID3, containerIncom);
         final BaseBestPath processedPathIncom = this.selector.result();
         assertEquals(BgpOrigin.Incomplete, processedPathIncom.getState().getOrigin());
 
-        final ContainerNode containerException = dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME).addChild(createValueBuilder("LOL", ORIGIN_Q_NAME, "value").build()).build()).build();
-        this.selector.processPath(this.ROUTER_ID3, containerException);
+        final ContainerNode containerException = dataContBuilder.addChild(createContBuilder(ORIGIN_Q_NAME)
+                .addChild(createValueBuilder("LOL", ORIGIN_Q_NAME, "value").build()).build()).build();
+        this.selector.processPath(ROUTER_ID3, containerException);
         final BaseBestPath processedPathException = this.selector.result();
         processedPathException.getState().getOrigin();
     }
index bc66b4c75563cf3eb5fa114e55dcf57729b4fc65..3accb42d0386fd6be57139b3ebd149825a1bed2f 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
 import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.mode.impl.AbstractRouteEntryTest;
@@ -39,22 +37,22 @@ public class BaseRouteEntryTest extends AbstractRouteEntryTest {
     }
 
     private void testRemoveRoute() {
-        Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(8, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaYii));
         this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID);
         this.testBARE.selectBest(AS);
         this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA);
-        yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        yiiCount = collectInfo();
         assertFalse(yiiCount.containsKey(this.routePaYii));
         assertFalse(yiiCount.containsKey(this.routeAddRiboutAttYii));
     }
 
     private void testInitializePeerWithExistentRoute() {
-        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport, this.tx);
-        assertEquals(8, this.yIIChanges.size());
-        final Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream()
-            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport,
+                this.tx);
+        assertEquals(8, this.yiichanges.size());
+        Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(1, (long) yiiCount.get(this.routeRiboutYiiPeer2));
         assertEquals(1, (long) yiiCount.get(this.routeRiboutAttYiiPeer2));
     }
@@ -70,13 +68,14 @@ public class BaseRouteEntryTest extends AbstractRouteEntryTest {
         assertFalse(this.testBARE.getOffsets().isEmpty());
         this.testBARE.selectBest(AS);
         this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA);
-        Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
         assertEquals(3, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaYii));
         assertEquals(1, (long) yiiCount.get(this.routeRiboutYii));
         assertEquals(1, (long) yiiCount.get(this.routeRiboutAttYii));
-        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx, ROUTE_ID_PA_ADD_PATH);
-        yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.tx,
+                ROUTE_ID_PA_ADD_PATH);
+        yiiCount = collectInfo();
         assertEquals(6, yiiCount.size());
         assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
         assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
@@ -84,7 +83,8 @@ public class BaseRouteEntryTest extends AbstractRouteEntryTest {
     }
 
     private void testWriteEmptyBestPath() {
-        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport, this.tx);
-        assertEquals(0, this.yIIChanges.size());
+        this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport,
+                this.tx);
+        assertEquals(0, this.yiichanges.size());
     }
 }
index 9cc65baf83c89c2b68dc1099c64d97d7621989d1..03b58fc5bfc4ea5b490436e6fcccb0f134a32dd4 100644 (file)
@@ -234,7 +234,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         final UnsignedInteger routerId = RouterIds.routerIdForPeerId(peerId);
         final Collection<DataTreeCandidateNode> modifiedRoutes = this.ribSupport.changedRoutes(child);
         for (final DataTreeCandidateNode route : modifiedRoutes) {
-            final PathArgument routeId = this.ribSupport.createRouteKeyPathArgument(route.getIdentifier());
+            final NodeIdentifierWithPredicates routeId = (NodeIdentifierWithPredicates)
+                    this.ribSupport.createRouteKeyPathArgument(route.getIdentifier());
             RouteEntry entry = this.routeEntries.get(routeId);
             final Optional<NormalizedNode<?, ?>> maybeData = route.getDataAfter();
             final Optional<NormalizedNode<?, ?>> maybeDataBefore = route.getDataBefore();
index c3693bda79d2d90d1f4718b38211350dbf504422..f76750b247b9d92f265abb20b24b3036a1ec4713 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import static java.util.Objects.requireNonNull;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 
 /**
  * Combined key formed as a concatenation of source peer and route identifiers.
@@ -18,9 +18,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
  */
 final class RouteUpdateKey {
     private final PeerId peerId;
-    private final PathArgument routeId;
+    private final NodeIdentifierWithPredicates routeId;
 
-    RouteUpdateKey(final PeerId peerId, final PathArgument routeId) {
+    RouteUpdateKey(final PeerId peerId, final NodeIdentifierWithPredicates routeId) {
         this.peerId = requireNonNull(peerId);
         this.routeId = requireNonNull(routeId);
     }
@@ -29,7 +29,7 @@ final class RouteUpdateKey {
         return this.peerId;
     }
 
-    PathArgument getRouteId() {
+    NodeIdentifierWithPredicates getRouteId() {
         return this.routeId;
     }
 
index ab5e48755412f966d8d7453033d4bdf726488431..f750bb8630c1331a2b0036f1235154c1c97e6d2a 100644 (file)
@@ -59,7 +59,7 @@ public interface ExportPolicyPeerTracker {
      * @param peerId of peer
      * @return Role of peer
      */
-    @Nullable
+    @Nonnull
     PeerRole getRole(@Nonnull YangInstanceIdentifier peerId);
 
     /**
index fa8dc0248af298b249c0fd90fa12fe019249daf9..f91d13953fb80a3d9580b318c8b8b973d6b7d6f8 100644 (file)
@@ -11,13 +11,19 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
 
+import com.google.common.collect.ImmutableMap;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4Route;
 
 public class AddPathRibSupportTest {
 
-    private static final NodeIdentifier QNAME = new NodeIdentifier(QName.create("test").intern());
+    private static final String PREFIX = "1.2.3.4/32";
+    private static final String ROUTE_KEY = "prefix";
+    private static final NodeIdentifierWithPredicates QNAME
+            = new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
+            ImmutableMap.of(QName.create(Ipv4Route.QNAME, ROUTE_KEY).intern(), PREFIX));
 
     @Test
     public void defaultAddPathRibSupport() {