Improve synchronization under BMP 67/52167/4
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 22 Feb 2017 11:35:38 +0000 (12:35 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 6 Apr 2017 07:08:00 +0000 (09:08 +0200)
Improve synchronization under BMP whenever
transaction chain is created and submitted.

Change-Id: If7a61c394218bd7c78c6021ee19ba42f4276560a
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bgp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitoringStationImpl.java
bgp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpRibInWriter.java
bgp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpRouterImpl.java
bgp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpRouterPeerImpl.java

index d0b659cbdb3f1a64de3cbe207f91ba764341fbcb..950804496f90971b1664370d660dd8a630b5b7af 100644 (file)
@@ -125,7 +125,7 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation {
         wTx.merge(LogicalDatastoreType.OPERATIONAL, path, parentNode);
     }
 
-    private void createEmptyMonitor() {
+    private synchronized void createEmptyMonitor() {
         final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
         ensureParentExists(wTx, YangInstanceIdentifier.of(BmpMonitor.QNAME));
         wTx.put(LogicalDatastoreType.OPERATIONAL,
@@ -143,7 +143,7 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation {
     }
 
     @Override
-    public void close() throws Exception {
+    public synchronized void close() throws Exception {
         this.channel.close().addListener((ChannelFutureListener) channelFuture -> BmpMonitoringStationImpl.this.sessionManager.close()).await();
 
         final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
index 9f69f93b68c4780817ac93daaa6380dec2e76455..803fee00cca1ab27a02725845711d2356fee6e24 100644 (file)
@@ -142,7 +142,7 @@ final class BmpRibInWriter {
         return tb;
     }
 
-    private void addRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+    private synchronized void addRoutes(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);
@@ -158,7 +158,7 @@ final class BmpRibInWriter {
         tx.submit();
     }
 
-    private void removeRoutes(final MpUnreachNlri nlri) {
+    private synchronized void removeRoutes(final MpUnreachNlri nlri) {
         final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
         final TableContext ctx = this.tables.get(key);
 
@@ -253,7 +253,7 @@ final class BmpRibInWriter {
         return isEOR;
     }
 
-    private void markTableUptodated(final TablesKey tableTypes) {
+    private synchronized void markTableUptodated(final TablesKey tableTypes) {
         final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
         final TableContext ctxPre = this.tables.get(tableTypes);
         tx.merge(LogicalDatastoreType.OPERATIONAL, ctxPre.getTableId().node(BMP_ATTRIBUTES_QNAME).node(ATTRIBUTES_UPTODATE_TRUE.getNodeType()),
index 4bf05fc35f53af2d19760d7920b3e522f1359e3e..498e063215f7f2def24edf49125800c0ea7fde72 100644 (file)
@@ -128,7 +128,7 @@ public class BmpRouterImpl implements BmpRouter, TransactionChainListener {
         if (this.session != null) {
             try {
                 this.session.close();
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 LOG.error("Fail to close session.", e);
             }
         }
@@ -186,7 +186,7 @@ public class BmpRouterImpl implements BmpRouter, TransactionChainListener {
         return (this.routerYangIId != null);
     }
 
-    private void createRouterEntry() {
+    private synchronized void createRouterEntry() {
         Preconditions.checkState(isDatastoreWritable());
         final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL, this.routerYangIId,
@@ -198,7 +198,7 @@ public class BmpRouterImpl implements BmpRouter, TransactionChainListener {
         wTx.submit();
     }
 
-    private void onInitiate(final InitiationMessage initiation) {
+    private synchronized void onInitiate(final InitiationMessage initiation) {
         Preconditions.checkState(isDatastoreWritable());
         final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
         wTx.merge(LogicalDatastoreType.OPERATIONAL, this.routerYangIId,
index 89f30d943b4314fc757847a524b4aab30af167d9..50613b1f71325572524d9b9c7f144ef6cbff7e48 100644 (file)
@@ -178,7 +178,7 @@ public final class BmpRouterPeerImpl implements BmpRouterPeer {
         }
     }
 
-    private void onStatsReports(final StatsReportsMessage statsReports) {
+    private synchronized void onStatsReports(final StatsReportsMessage statsReports) {
         if (this.up) {
             final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
             wTx.merge(LogicalDatastoreType.OPERATIONAL, this.peerYangIId.node(Stats.QNAME),
@@ -187,7 +187,7 @@ public final class BmpRouterPeerImpl implements BmpRouterPeer {
         }
     }
 
-    private void onRouteMirror(final RouteMirroringMessage mirror) {
+    private synchronized void onRouteMirror(final RouteMirroringMessage mirror) {
         final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
         wTx.merge(LogicalDatastoreType.OPERATIONAL, this.peerYangIId.node(Mirrors.QNAME),
                 createMirrors(mirror, mirror.getPeerHeader().getTimestampSec()));
@@ -195,7 +195,7 @@ public final class BmpRouterPeerImpl implements BmpRouterPeer {
     }
 
 
-    private void onPeerDown() {
+    private synchronized void onPeerDown() {
         final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, this.peerYangIId);
         wTx.submit();