BUG-8494: do not attempt to reconnect ReconnectingClientConnection
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / DsbenchmarkProvider.java
index f40efc3e2dc409e4fa106b472dcdeaf85f8c2641..8af7e15b9775c6af18fd7872f372effe55b00a1c 100644 (file)
@@ -53,20 +53,23 @@ import com.google.common.util.concurrent.Futures;
 public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkService, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(DsbenchmarkProvider.class);
-    private static final InstanceIdentifier<TestExec> TEST_EXEC_IID = InstanceIdentifier.builder(TestExec.class).build();
-    private static final InstanceIdentifier<TestStatus> TEST_STATUS_IID = InstanceIdentifier.builder(TestStatus.class).build();
+    private static final InstanceIdentifier<TestExec> TEST_EXEC_IID =
+            InstanceIdentifier.builder(TestExec.class).build();
+    private static final InstanceIdentifier<TestStatus> TEST_STATUS_IID =
+            InstanceIdentifier.builder(TestStatus.class).build();
 
-    private final AtomicReference<ExecStatus> execStatus = new AtomicReference<ExecStatus>( ExecStatus.Idle );
+    private final AtomicReference<ExecStatus> execStatus = new AtomicReference<>(ExecStatus.Idle);
     private final DsbenchmarkListenerProvider listenerProvider = new DsbenchmarkListenerProvider();
     private final DOMDataBroker domDataBroker;  // Async DOM Broker for use with all DOM operations
-    private final DataBroker bindingDataBroker; // Async Binding-Aware Broker for use in tx chains; initialized to ping-pong
-                                                // broker in default config (see default-config.xml and dsbenchmark-impl.yang)
+    private final DataBroker bindingDataBroker; // Async Binding-Aware Broker for use in tx chains; initialized to
+                                                // ping-pong broker in default config (see default-config.xml and
+                                                // dsbenchmark-impl.yang)
     private DataBroker dataBroker;              // "Legacy" OSGI Data Broker for use in simple transactions
     private RpcRegistration<DsbenchmarkService> dstReg;
 
     private long testsCompleted = 0;
 
-    public DsbenchmarkProvider(DOMDataBroker domDataBroker, DataBroker bindingDataBroker) {
+    public DsbenchmarkProvider(final DOMDataBroker domDataBroker, final DataBroker bindingDataBroker) {
         // We have to get the DOMDataBroker via the constructor,
         // since we can't get it from the session
         this.domDataBroker = domDataBroker;
@@ -74,30 +77,30 @@ public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkSer
     }
 
     @Override
-    public void onSessionInitiated(ProviderContext session) {
+    public void onSessionInitiated(final ProviderContext session) {
         this.dataBroker = session.getSALService(DataBroker.class);
         this.dstReg = session.addRpcImplementation( DsbenchmarkService.class, this );
         listenerProvider.setDataBroker(dataBroker);
         setTestOperData(this.execStatus.get(), testsCompleted);
 
-        LOG.info("DsbenchmarkProvider Session Initiated");
+        LOG.debug("DsbenchmarkProvider Session Initiated");
     }
 
     @Override
     public void close() throws Exception {
         dstReg.close();
-        LOG.info("DsbenchmarkProvider Closed");
+        LOG.debug("DsbenchmarkProvider Closed");
     }
 
     @Override
     public Future<RpcResult<Void>> cleanupStore() {
         cleanupTestStore();
-        LOG.info("Data Store cleaned up");
-        return Futures.immediateFuture( RpcResultBuilder.<Void> success().build() );
+        LOG.debug("Data Store cleaned up");
+        return Futures.immediateFuture( RpcResultBuilder.<Void>success().build());
     }
 
     @Override
-    public Future<RpcResult<StartTestOutput>> startTest(StartTestInput input) {
+    public Future<RpcResult<StartTestOutput>> startTest(final StartTestInput input) {
         LOG.info("Starting the data store benchmark test, input: {}", input);
 
         // Check if there is a test in progress
@@ -133,7 +136,7 @@ public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkSer
 
             this.testsCompleted++;
 
-        } catch ( Exception e ) {
+        } catch (final Exception e) {
             LOG.error( "Test error: {}", e.toString());
             execStatus.set( ExecStatus.Idle );
             return RpcResultBuilder.success(new StartTestOutputBuilder()
@@ -146,6 +149,7 @@ public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkSer
         execStatus.set(ExecStatus.Idle);
 
         // Get the number of data change events and cleanup the data change listeners
+        long numDataChanges = listenerProvider.getDataChangeCount();
         long numEvents = listenerProvider.getEventCountAndDestroyListeners();
 
         StartTestOutput output = new StartTestOutputBuilder()
@@ -154,13 +158,14 @@ public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkSer
                 .setExecTime(execTime)
                 .setTxOk((long)dsWriter.getTxOk())
                 .setNtfOk(numEvents)
+                .setDataChangeEventsOk(numDataChanges)
                 .setTxError((long)dsWriter.getTxError())
                 .build();
 
         return RpcResultBuilder.success(output).buildFuture();
     }
 
-    private void setTestOperData( ExecStatus sts, long tstCompl ) {
+    private void setTestOperData( final ExecStatus sts, final long tstCompl ) {
         TestStatus status = new TestStatusBuilder()
                 .setExecStatus(sts)
                 .setTestsCompleted(tstCompl)
@@ -171,11 +176,11 @@ public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkSer
 
         try {
             tx.submit().checkedGet();
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             throw new IllegalStateException(e);
         }
 
-        LOG.info("DataStore test oper status populated: {}", status);
+        LOG.debug("DataStore test oper status populated: {}", status);
     }
 
     private void cleanupTestStore() {
@@ -187,25 +192,25 @@ public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkSer
         tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data);
         try {
             tx.submit().checkedGet();
-            LOG.info("DataStore config test data cleaned up");
-        } catch (TransactionCommitFailedException e) {
+            LOG.debug("DataStore config test data cleaned up");
+        } catch (final TransactionCommitFailedException e) {
             LOG.info("Failed to cleanup DataStore configtest data");
             throw new IllegalStateException(e);
         }
-        
+
         tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID, data);
         try {
             tx.submit().checkedGet();
-            LOG.info("DataStore operational test data cleaned up");
-        } catch (TransactionCommitFailedException e) {
+            LOG.debug("DataStore operational test data cleaned up");
+        } catch (final TransactionCommitFailedException e) {
             LOG.info("Failed to cleanup DataStore operational test data");
             throw new IllegalStateException(e);
         }
 
     }
 
-    private DatastoreAbstractWriter getDatastoreWriter(StartTestInput input) {
+    private DatastoreAbstractWriter getDatastoreWriter(final StartTestInput input) {
 
         final DatastoreAbstractWriter retVal;