Improve bmp synchronization 55/72355/1
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Sat, 26 May 2018 21:07:57 +0000 (23:07 +0200)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Sat, 26 May 2018 21:08:23 +0000 (23:08 +0200)
Change-Id: If5d90f32d6f72b0f1c07a7ff63db4afeb4391772
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpRouterImpl.java

index 03f6de0e4ba05e6d17644161d3a9819599df372c..6390fa97623930420a060233cc9c529434b0ab34 100644 (file)
@@ -109,7 +109,7 @@ public final class BmpRouterImpl implements BmpRouter, TransactionChainListener
     }
 
     @Override
-    public void onSessionDown(final Exception exception) {
+    public synchronized void onSessionDown(final Exception exception) {
         // we want to tear down as we want to do clean up like closing the transaction chain, etc.
         // even when datastore is not writable (routerYangIId == null / redundant session)
         tearDown();
@@ -183,7 +183,8 @@ public final class BmpRouterImpl implements BmpRouter, TransactionChainListener
     }
 
     @Override
-    public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
+    public synchronized void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+            final AsyncTransaction<?, ?> transaction,
         final Throwable cause) {
         LOG.error("Transaction chain failed.", cause);
     }
@@ -193,7 +194,7 @@ public final class BmpRouterImpl implements BmpRouter, TransactionChainListener
         LOG.debug("Transaction chain {} successfully.", chain);
     }
 
-    private boolean isDatastoreWritable() {
+    private synchronized boolean isDatastoreWritable() {
         return (this.routerYangIId != null);
     }