Bug 8829: Ignore error when initializing dsbenchmark 17/52317/7
authorVratko Polak <vrpolak@cisco.com>
Mon, 10 Jul 2017 10:51:18 +0000 (12:51 +0200)
committerVratko Polak <vrpolak@cisco.com>
Wed, 4 Oct 2017 12:50:42 +0000 (14:50 +0200)
+ Also fix ParenPad violations.

Change-Id: I6f4902bb8236fc1560e1e38554465aefadb775ee
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java

index 467f35c..229eddf 100644 (file)
@@ -72,7 +72,14 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
 
     public void init() {
         listenerProvider.setDataBroker(simpleTxDataBroker);
-        setTestOperData(this.execStatus.get(), testsCompleted);
+
+        try {
+            // We want to set the initial operation status so users can detect we are ready to start test.
+            setTestOperData(this.execStatus.get(), testsCompleted);
+        } catch (final Exception e) {
+            // TODO: Use a singleton service to make sure the initial write is performed only once.
+            LOG.warn("Working around Bugs 8829 and 6793 by ignoring exception from setTestOperData: {}", e);
+        }
 
         LOG.info("DsbenchmarkProvider initiated");
     }
@@ -86,7 +93,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     public Future<RpcResult<Void>> cleanupStore() {
         cleanupTestStore();
         LOG.debug("Data Store cleaned up");
-        return Futures.immediateFuture( RpcResultBuilder.<Void>success().build());
+        return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
     }
 
     @Override
@@ -94,7 +101,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
         LOG.info("Starting the data store benchmark test, input: {}", input);
 
         // Check if there is a test in progress
-        if ( execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing) == false ) {
+        if (execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing) == false) {
             LOG.info("Test in progress");
             return RpcResultBuilder.success(new StartTestOutputBuilder()
                     .setStatus(StartTestOutput.Status.TESTINPROGRESS)
@@ -127,15 +134,15 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             this.testsCompleted++;
 
         } catch (final Exception e) {
-            LOG.error( "Test error: {}", e.toString());
-            execStatus.set( ExecStatus.Idle );
+            LOG.error("Test error: {}", e.toString());
+            execStatus.set(ExecStatus.Idle);
             return RpcResultBuilder.success(new StartTestOutputBuilder()
                     .setStatus(StartTestOutput.Status.FAILED)
                     .build()).buildFuture();
         }
 
         LOG.info("Test finished");
-        setTestOperData( ExecStatus.Idle, testsCompleted);
+        setTestOperData(ExecStatus.Idle, testsCompleted);
         execStatus.set(ExecStatus.Idle);
 
         // Get the number of data change events and cleanup the data change listeners
@@ -155,7 +162,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
         return RpcResultBuilder.success(output).buildFuture();
     }
 
-    private void setTestOperData( final ExecStatus sts, final long tstCompl ) {
+    private void setTestOperData(final ExecStatus sts, final long tstCompl) {
         TestStatus status = new TestStatusBuilder()
                 .setExecStatus(sts)
                 .setTestsCompleted(tstCompl)

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.