Revert "BUG-5742: Race condition when creating Application Peer on clustering" 37/42737/1
authorMilos Fabian <milfabia@cisco.com>
Thu, 28 Jul 2016 19:14:39 +0000 (21:14 +0200)
committerMilos Fabian <milfabia@cisco.com>
Thu, 28 Jul 2016 19:28:36 +0000 (21:28 +0200)
This reverts commit b07d1c31f6ed622770cb8cc28658ab8f56a81102.

Change-Id: Iab27b13ff9874a59ae5e4e5c2b95153987db1419
Signed-off-by: Milos Fabian <milfabia@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java

index 5441e33a0ac4b4dcb5706cdbd7d37d7bd81849ff..2472b5cdf941d1205aab086b40e123589ef006e7 100644 (file)
@@ -57,6 +57,7 @@ public class ApplicationPeer implements AutoCloseable, org.opendaylight.protocol
     private final String name;
     private final YangInstanceIdentifier adjRibsInId;
     private final DOMTransactionChain chain;
+    private final DOMTransactionChain writerChain;
     private final BGPConfigModuleTracker moduleTracker;
     private final EffectiveRibInWriter effectiveRibInWriter;
 
@@ -70,10 +71,11 @@ public class ApplicationPeer implements AutoCloseable, org.opendaylight.protocol
         final YangInstanceIdentifier peerIId = this.targetRib.getYangRibId().node(Peer.QNAME).node(peerId);
         this.adjRibsInId = peerIId.node(AdjRibIn.QNAME).node(Tables.QNAME);
         this.chain = this.targetRib.createPeerChain(this);
-        this.writer = AdjRibInWriter.create(this.targetRib.getYangRibId(), PeerRole.Internal, this.chain);
+        this.effectiveRibInWriter = EffectiveRibInWriter.create(this.targetRib.getService(), this.targetRib.createPeerChain(this), peerIId, this.targetRib.getImportPolicyPeerTracker(),
+                this.targetRib.getRibSupportContext(), PeerRole.Internal);
+        this.writerChain = this.targetRib.createPeerChain(this);
+        this.writer = AdjRibInWriter.create(this.targetRib.getYangRibId(), PeerRole.Internal, this.writerChain);
         this.writer = this.writer.transform(RouterIds.createPeerId(ipAddress), this.targetRib.getRibSupportContext(), this.targetRib.getLocalTablesKeys(), true);
-        this.effectiveRibInWriter = EffectiveRibInWriter.create(this.targetRib.getService(), this.chain, peerIId, this.targetRib.getImportPolicyPeerTracker(),
-            this.targetRib.getRibSupportContext(), PeerRole.Internal);
         this.moduleTracker = moduleTracker;
         if (moduleTracker != null) {
             moduleTracker.onInstanceCreate();
@@ -182,6 +184,7 @@ public class ApplicationPeer implements AutoCloseable, org.opendaylight.protocol
         this.effectiveRibInWriter.close();
         this.writer.removePeer();
         this.chain.close();
+        this.writerChain.close();
         if (this.moduleTracker != null) {
             this.moduleTracker.onInstanceClose();
         }