Bug 7011 - Race condition in statistics collection related transaction chain handling 79/47379/3
authorAnil Vishnoi <vishnoianil@gmail.com>
Sat, 22 Oct 2016 12:22:14 +0000 (05:22 -0700)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 27 Oct 2016 15:45:08 +0000 (15:45 +0000)
Change-Id: Iabc18b2814bf2f49bb6159f0bb8f9f55eda2e07d
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java

index 0912b37ec75a4d2fb29be16bf394800b6fa51ced..da4bdae04e427d42efd4ab7eebbf44e3b0b27e7d 100644 (file)
@@ -79,8 +79,9 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
 
     @GuardedBy("txLock")
     private void createTxChain() {
-        Optional.ofNullable(txChainFactory).ifPresent(TransactionChain::close);
+        BindingTransactionChain txChainFactoryTemp = txChainFactory;
         txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
+        Optional.ofNullable(txChainFactoryTemp).ifPresent(TransactionChain::close);
     }
 
     public void setLifecycleService(final LifecycleService lifecycleService) {
@@ -234,7 +235,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
     public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
                                          final AsyncTransaction<?, ?> transaction, final Throwable cause) {
         if (transactionChainManagerStatus.equals(TransactionChainManagerStatus.WORKING)) {
-            LOG.warn("txChain failed -> recreating due to {}", cause);
+            LOG.warn("Transaction chain failed, recreating chain due to ", cause);
             recreateTxChain();
         }
     }
index d190ca6ef0ea765362f67cabd72b629472d5ea53..f0bcbdcce43c73509569ac126d932591d1be5ea0 100644 (file)
@@ -140,7 +140,8 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
                 timeCounter.addTimeMark();
-                LOG.warn("Statistics gathering for single node {} was not successful: ", deviceInfo.getLOGValue(), throwable.getMessage());
+                LOG.warn("Statistics gathering for single node {} was not successful: {}", deviceInfo.getLOGValue(),
+                        throwable.getMessage());
                 if (LOG.isTraceEnabled()) {
                     LOG.trace("Gathering for node {} failure: ", deviceInfo.getLOGValue(), throwable);
                 }
@@ -335,4 +336,4 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         this.isStatisticsPollingOff = isStatisticsPollingOff;
     }
 
-}
\ No newline at end of file
+}