BUG-3074 : propagate up-to-date attribute 82/19782/2
authorDana Kutenicsova <dkutenic@cisco.com>
Wed, 6 May 2015 11:41:53 +0000 (13:41 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Thu, 7 May 2015 09:33:50 +0000 (09:33 +0000)
Added a method to BGPPeer that will notify the
peer that the synchronization for a table is finished.
Peer than pushes this information to AdjRibsIn from
where it's propagated to other types of RIB.

Change-Id: Idb7ad21b136b03fb2ded1bf3fe720319298555a0
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
(cherry picked from commit 45e441f5b159f616ae85bcf62c0e0d2432d485ad)

12 files changed:
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibInWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSynchronization.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionListener.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationTest.java
bgp/rib-mock/src/test/java/org/opendaylight/protocol/bgp/rib/mock/BGPListenerMock.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/BGPSessionListener.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java
bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/SpeakerSessionListener.java

index 0e1134e732e47f1611741b74f384d91babe7954f..6e619c64b3fdf260cae5834460966420ed0c4b0b 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
 import org.opendaylight.protocol.bgp.rib.spi.RibSupportUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
@@ -34,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.peer.EffectiveRibIn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Attributes;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
@@ -181,9 +181,8 @@ final class AdjRibInWriter {
                 idb.nodeWithKey(key.getNodeType(), key.getKeyValues());
                 ctx = new TableContext(rs, idb.build());
                 ctx.clearTable(tx);
-            } else {
-                tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(Attributes.QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getNodeType()), ATTRIBUTES_UPTODATE_FALSE);
             }
+            tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(Attributes.QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getNodeType()), ATTRIBUTES_UPTODATE_FALSE);
             LOG.debug("Created table instance {}", ctx.getTableId());
             tb.put(k, ctx);
         }
@@ -209,18 +208,16 @@ final class AdjRibInWriter {
         tx.submit();
     }
 
-    void markTablesUptodate(final Collection<TablesKey> tableTypes) {
+    void markTableUptodate(final TablesKey tableTypes) {
         final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
 
-        for (final TablesKey k : tableTypes) {
-            final TableContext ctx = this.tables.get(k);
-            tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Attributes.QNAME).node(ATTRIBUTES_UPTODATE_TRUE.getNodeType()), ATTRIBUTES_UPTODATE_TRUE);
-        }
+        final TableContext ctx = this.tables.get(tableTypes);
+        tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(Attributes.QNAME).node(ATTRIBUTES_UPTODATE_TRUE.getNodeType()), ATTRIBUTES_UPTODATE_TRUE);
 
         tx.submit();
     }
 
-    void updateRoutes(final MpReachNlri nlri, final Attributes attributes) {
+    void updateRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes attributes) {
         final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
         final TableContext ctx = this.tables.get(key);
         if (ctx == null) {
index c5e411ab89fa92f55a4be616536cbbc6d4eba74c..ab8f0e2d61fd6d24fbf55960293688e87f98b605 100644 (file)
@@ -91,7 +91,7 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
         this.rib = Preconditions.checkNotNull(rib);
         this.name = name;
         this.chain = rib.createPeerChain(this);
-        this.ribWriter = AdjRibInWriter.create(rib.getYangRibId(), role, chain);
+        this.ribWriter = AdjRibInWriter.create(rib.getYangRibId(), role, this.chain);
     }
 
     @Override
@@ -305,4 +305,9 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
     public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
         LOG.debug("Transaction chain {} successfull.", chain);
     }
+
+    @Override
+    public void markUptodate(final TablesKey tablesKey) {
+        this.ribWriter.markTableUptodate(tablesKey);
+    }
 }
index 5464c871fda93112df4a712bafba241a6a76a93c..b8f84c594a092ecfcef95c1b98c2b72b99e3c364 100644 (file)
@@ -146,7 +146,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
             }
         }
 
-        this.sync = new BGPSynchronization(this, this.listener, tts);
+        this.sync = new BGPSynchronization(this.listener, tts);
         this.tableTypes = tats;
 
         if (this.holdTimerValue != 0) {
index 7024374e648ca80eb98ef441ceb6fb88113ebefe..8c311942fc265371417dc390911cda8e4c91f89a 100644 (file)
@@ -7,20 +7,16 @@
  */
 package org.opendaylight.protocol.bgp.rib.impl;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.UpdateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlriBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
@@ -36,7 +32,8 @@ public class BGPSynchronization {
 
     private static final Logger LOG = LoggerFactory.getLogger(BGPSynchronization.class);
 
-    private static class SyncVariables {
+    @VisibleForTesting
+    static class SyncVariables {
 
         private boolean upd = false;
         private boolean eor = false;
@@ -58,15 +55,13 @@ public class BGPSynchronization {
         }
     }
 
-    private final Map<TablesKey, SyncVariables> syncStorage = Maps.newHashMap();
+    @VisibleForTesting
+    public final Map<TablesKey, SyncVariables> syncStorage = Maps.newHashMap();
 
     private final BGPSessionListener listener;
 
-    private final BGPSession session;
-
-    public BGPSynchronization(final BGPSession bgpSession, final BGPSessionListener listener, final Set<TablesKey> types) {
+    public BGPSynchronization(final BGPSessionListener listener, final Set<TablesKey> types) {
         this.listener = Preconditions.checkNotNull(listener);
-        this.session = Preconditions.checkNotNull(bgpSession);
 
         for (final TablesKey type : types) {
             this.syncStorage.put(type, new SyncVariables());
@@ -114,6 +109,7 @@ public class BGPSynchronization {
         s.setUpd(true);
         if (isEOR) {
             s.setEorTrue();
+            this.listener.markUptodate(type);
             LOG.info("BGP Synchronization finished for table {} ", type);
         }
     }
@@ -130,20 +126,10 @@ public class BGPSynchronization {
                 if (!s.getUpd()) {
                     s.setEorTrue();
                     LOG.info("BGP Synchronization finished for table {} ", entry.getKey());
-                    final Update up = generateEOR(entry.getKey());
-                    LOG.debug("Sending synchronization message: {}", up);
-                    this.listener.onMessage(this.session, up);
+                    this.listener.markUptodate(entry.getKey());
                 }
                 s.setUpd(false);
             }
         }
     }
-
-    private Update generateEOR(final TablesKey type) {
-        return new UpdateBuilder().setAttributes(
-                new AttributesBuilder().addAugmentation(
-                        Attributes2.class,
-                        new Attributes2Builder().setMpUnreachNlri(
-                                new MpUnreachNlriBuilder().setAfi(type.getAfi()).setSafi(type.getSafi()).build()).build()).build()).build();
-    }
 }
index 87e3d0f4a8652302a3f5e466549858464edeb015..0b57184df312b27f86141d8fc8d90861ecf6c550 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.peer.EffectiveRibIn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -67,7 +68,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
         final DOMDataTreeChangeService service, final PolicyDatabase pd, final TablesKey tablesKey) {
         this.chain = Preconditions.checkNotNull(chain);
         this.tableKey = RibSupportUtils.toYangTablesKey(tablesKey);
-        this.locRibTarget = YangInstanceIdentifier.create(target.node(LocRib.QNAME).node(Tables.QNAME).node(this.tableKey).node(Routes.QNAME).getPathArguments());
+        this.locRibTarget = YangInstanceIdentifier.create(target.node(LocRib.QNAME).node(Tables.QNAME).node(this.tableKey).getPathArguments());
         this.ourAs = Preconditions.checkNotNull(ourAs);
         this.registry = registry;
         this.ribSupport = this.registry.getRIBSupportContext(tablesKey).getRibSupport();
@@ -75,7 +76,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
         this.peerPolicyTracker = new ExportPolicyPeerTracker(service, target, pd);
 
         final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
-        tx.merge(LogicalDatastoreType.OPERATIONAL, this.locRibTarget, this.ribSupport.emptyRoutes());
+        tx.merge(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(Routes.QNAME), this.ribSupport.emptyRoutes());
         tx.submit();
 
         final YangInstanceIdentifier tableId = target.node(Peer.QNAME).node(Peer.QNAME).node(EffectiveRibIn.QNAME).node(Tables.QNAME).node(this.tableKey);
@@ -115,6 +116,12 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
             final PeerId peerId = IdentifierUtils.peerId(peerKey);
             final UnsignedInteger routerId = RouterIds.routerIdForPeerId(peerId);
             for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
+                if ((Attributes.QNAME).equals(child.getIdentifier().getNodeType())) {
+                    // putting uptodate attribute in
+                    LOG.trace("Uptodate found for {}", child.getDataAfter());
+                    tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get());
+                    continue;
+                }
                 for (final DataTreeCandidateNode route : this.ribSupport.changedRoutes(child)) {
                     final PathArgument routeId = route.getIdentifier();
                     AbstractRouteEntry entry = this.routeEntries.get(routeId);
@@ -155,7 +162,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
                 value = null;
             }
 
-            final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget, e.getKey().getRouteId());
+            final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget.node(Routes.QNAME), e.getKey().getRouteId());
             if (value != null) {
                 LOG.debug("Write route to LocRib {}", value);
                 tx.put(LogicalDatastoreType.OPERATIONAL, writePath, value);
index 4db0248b46766450a2b0672bfc68f6e3450556fc..53560ace94cc660ebe936c29f0f9c62fbed801c3 100644 (file)
@@ -12,6 +12,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,4 +72,9 @@ public class SimpleSessionListener implements ReusableBGPPeer {
     public boolean isSessionActive() {
         return true;
     }
+
+    @Override
+    public void markUptodate(final TablesKey tablesKey) {
+        LOG.debug("Table marked as up-to-date {}", tablesKey);
+    }
 }
index 4e49257f3df65a57c52b16e97e974c25e8fedea1..09866808263d4411f752d4b9eaa0ee56b16e3d9b 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,4 +65,9 @@ public class SpeakerSessionListener implements BGPSessionListener {
     public boolean isSessionActive() {
         return true;
     }
+
+    @Override
+    public void markUptodate(final TablesKey tablesKey) {
+        LOG.debug("Table marked as up-to-date {}", tablesKey);
+    }
 }
index c9658aac5ce7e15ce66b8610dbf0ae130a23d863..b67022f0acce86c68e50d474f880682c79f89705 100644 (file)
@@ -8,16 +8,13 @@
 package org.opendaylight.protocol.bgp.rib.impl;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateSubsequentAddressFamily;
@@ -27,8 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.update.NlriBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlriBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
@@ -37,6 +32,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 
 public class SynchronizationTest {
 
+    private final TablesKey ipv4 = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+    private final TablesKey linkstate = new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
+
     private BGPSynchronization bs;
 
     private SimpleSessionListener listener;
@@ -74,34 +72,7 @@ public class SynchronizationTest {
 
         this.eorm = new UpdateBuilder().build();
 
-        final Set<TablesKey> types = Sets.newHashSet();
-        types.add(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
-        types.add(new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
-
-        this.bs = new BGPSynchronization(new BGPSession() {
-
-            @Override
-            public void close() {
-            }
-
-            @Override
-            public Set<BgpTableType> getAdvertisedTableTypes() {
-                final Set<BgpTableType> types = Sets.newHashSet();
-                types.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
-                types.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
-                return types;
-            }
-
-            @Override
-            public Ipv4Address getBgpId() {
-                return new Ipv4Address("127.0.0.1");
-            }
-
-            @Override
-            public AsNumber getAsNumber() {
-                return new AsNumber(30L);
-            }
-        }, this.listener, types);
+        this.bs = new BGPSynchronization(this.listener, Sets.newHashSet(this.ipv4, this.linkstate));
     }
 
     @Test
@@ -111,13 +82,13 @@ public class SynchronizationTest {
         this.bs.updReceived(this.ipv4m);
         this.bs.updReceived(this.lsm);
         this.bs.kaReceived(); // nothing yet
+        assertFalse(this.bs.syncStorage.get(this.linkstate).getEor());
+        assertFalse(this.bs.syncStorage.get(this.ipv4).getEor());
         this.bs.updReceived(this.ipv4m);
         this.bs.kaReceived(); // linkstate
-        assertEquals(1, this.listener.getListMsg().size());
-        assertEquals(LinkstateAddressFamily.class, ((Update) this.listener.getListMsg().get(0)).getAttributes().getAugmentation(
-                Attributes2.class).getMpUnreachNlri().getAfi());
+        assertTrue(this.bs.syncStorage.get(this.linkstate).getEor());
         this.bs.kaReceived(); // ipv4 sync
-        assertEquals(2, this.listener.getListMsg().size());
+        assertTrue(this.bs.syncStorage.get(this.ipv4).getEor());
     }
 
     @Test
@@ -125,14 +96,15 @@ public class SynchronizationTest {
         this.bs.updReceived(this.ipv4m);
         this.bs.updReceived(this.lsm);
         // Ipv4 Unicast synchronized by EOR message
+        assertFalse(this.bs.syncStorage.get(this.ipv4).getEor());
         this.bs.updReceived(this.eorm);
+        assertTrue(this.bs.syncStorage.get(this.ipv4).getEor());
         // Linkstate not synchronized yet
+        assertFalse(this.bs.syncStorage.get(this.linkstate).getEor());
         this.bs.kaReceived();
         // no message sent by BGPSychchronization
         assertEquals(0, this.listener.getListMsg().size());
         this.bs.kaReceived();
-        assertEquals(1, this.listener.getListMsg().size());
-        assertEquals(LinkstateAddressFamily.class, ((Update) this.listener.getListMsg().get(0)).getAttributes().getAugmentation(
-                Attributes2.class).getMpUnreachNlri().getAfi());
+        assertTrue(this.bs.syncStorage.get(this.linkstate).getEor());
     }
 }
index d7b4e6c0a15c3ba830da8fc5733a5dcce8c6dbc9..9b34e7f6e73d84cda7619285cdb3c7784a4c5804 100644 (file)
@@ -13,6 +13,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
@@ -55,4 +56,8 @@ public final class BGPListenerMock implements BGPSessionListener {
     public boolean isSessionActive() {
         return true;
     }
+
+    @Override
+    public void markUptodate(final TablesKey tablesKey) {
+    }
 }
index a6127ba9ca1e26455db0538c8a43e0ea509b9ca1..06f138c0e4fc36174fe4e2b694f8821b5a9e142c 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.rib.spi;
 
 import org.opendaylight.protocol.framework.SessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
@@ -21,4 +22,11 @@ public interface BGPSessionListener extends SessionListener<Notification, BGPSes
      * @return false if session associated with this listener is null, true if its non-null
      */
     boolean isSessionActive();
+
+    /**
+     * Marks synchronization finished for given Table key
+     *
+     * @param tablesKey of the table where synchronization finished
+     */
+    void markUptodate(final TablesKey tablesKey);
 }
index c66119ad62b0881948e8963144bb17ab30df5b30..6e981cd5ec27268e2ec4191034bcb5f2785a0c2f 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.testtool;
 import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,4 +51,9 @@ public class TestingListener implements ReusableBGPPeer {
     public boolean isSessionActive() {
         return true;
     }
+
+    @Override
+    public void markUptodate(final TablesKey tablesKey) {
+        LOG.debug("Table marked as up-to-date {}", tablesKey);
+    }
 }
index 4c6a42d757d26f1be71606af419394a0ccfba3ff..bf49d1082a75e149a553765207b9284c44500720 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.testtool;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,4 +45,9 @@ public class SpeakerSessionListener implements BGPSessionListener {
     public boolean isSessionActive() {
         return true;
     }
+
+    @Override
+    public void markUptodate(final TablesKey tablesKey) {
+        LOG.debug("Table marked as up-to-date {}", tablesKey);
+    }
 }