BUG-4867: AdjRibOutListener is one per Table 25/32325/3
authorClaudio D. Gasparini <cgaspari@cisco.com>
Sun, 10 Jan 2016 12:58:12 +0000 (13:58 +0100)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Mon, 11 Jan 2016 22:14:39 +0000 (23:14 +0100)
AdjRibOutListener is one per Table, therefore we need to store all
of them for later close.

Change-Id: Ied60bd9046dc21f03cb6d45418f0348109c66ae5
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java

index e7212e3062b68ffd94fdb18361f71a87758195b9..c3d2480a59b89505797eb99eac4e81f97d340b74 100644 (file)
@@ -85,7 +85,7 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer
     private BGPPeerRuntimeRegistrator registrator;
     private BGPPeerRuntimeRegistration runtimeReg;
     private long sessionEstablishedCounter = 0L;
-    private AdjRibOutListener adjRibOutListener;
+    private final Set<AdjRibOutListener> adjRibOutListenerSet = new HashSet<>();
 
     public BGPPeer(final String name, final RIB rib) {
         this(name, rib, PeerRole.Ibgp);
@@ -228,14 +228,17 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer
 
         // not particularly nice
         if (context != null && this.session instanceof BGPSessionImpl) {
-            this.adjRibOutListener = AdjRibOutListener.create(peerId, key, this.rib.getYangRibId(), this.rib.getCodecsRegistry(), context.getRibSupport(),
-                ((RIBImpl) this.rib).getService(), ((BGPSessionImpl) this.session).getLimiter(), mpSupport);
+            this.adjRibOutListenerSet.add(AdjRibOutListener.create(peerId, key, this.rib.getYangRibId(), this.rib.getCodecsRegistry(),
+                context.getRibSupport(), ((RIBImpl) this.rib).getService(), ((BGPSessionImpl) this.session).getLimiter(), mpSupport));
         }
     }
 
     private synchronized void cleanup() {
         // FIXME: BUG-196: support graceful
-        this.adjRibOutListener.close();
+        for (final AdjRibOutListener adjRibOutListener : this.adjRibOutListenerSet) {
+            adjRibOutListener.close();
+        }
+        this.adjRibOutListenerSet.clear();
         this.ribWriter.cleanTables(this.tables);
         this.tables.clear();
     }