Bump odlparent/yangtools/mdsal
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / DsbenchmarkProvider.java
index 0cf0195ca41acccd8f4fc79bbcc9d36a48b4edc3..eea490a3c7180130af0b51d7bde6f575920a43e0 100644 (file)
@@ -41,10 +41,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchm
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatus.ExecStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatusBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,30 +59,25 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     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 txChainDataBroker; // 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 simpleTxDataBroker;      // "Legacy" OSGI Data Broker for use in simple transactions
+    private final DataBroker dataBroker; // Async Binding-Aware Broker for use in tx chains
 
     private long testsCompleted = 0;
 
-    public DsbenchmarkProvider(final DOMDataBroker domDataBroker, final DataBroker txChainDataBroker,
-            final DataBroker simpleTxDataBroker) {
+    public DsbenchmarkProvider(final DOMDataBroker domDataBroker, final DataBroker dataBroker) {
         this.domDataBroker = domDataBroker;
-        this.txChainDataBroker = txChainDataBroker;
-        this.simpleTxDataBroker = simpleTxDataBroker;
+        this.dataBroker = dataBroker;
     }
 
     @SuppressWarnings("checkstyle:illegalCatch")
     public void init() {
-        listenerProvider.setDataBroker(simpleTxDataBroker);
+        listenerProvider.setDataBroker(dataBroker);
 
         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.warn("Working around Bugs 8829 and 6793 by ignoring exception from setTestOperData", e);
         }
 
         LOG.info("DsbenchmarkProvider initiated");
@@ -158,10 +153,10 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
                 .setStatus(StartTestOutput.Status.OK)
                 .setListBuildTime(listCreateTime)
                 .setExecTime(execTime)
-                .setTxOk((long)dsWriter.getTxOk())
-                .setNtfOk(numEvents)
-                .setDataChangeEventsOk(numDataChanges)
-                .setTxError((long)dsWriter.getTxError())
+                .setTxOk(Uint32.valueOf(dsWriter.getTxOk()))
+                .setNtfOk(Uint32.valueOf(numEvents))
+                .setDataChangeEventsOk(Uint32.valueOf(numDataChanges))
+                .setTxError(Uint32.valueOf(dsWriter.getTxError()))
                 .build();
 
         return RpcResultBuilder.success(output).buildFuture();
@@ -170,10 +165,10 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     private void setTestOperData(final ExecStatus sts, final long tstCompl) {
         TestStatus status = new TestStatusBuilder()
                 .setExecStatus(sts)
-                .setTestsCompleted(tstCompl)
+                .setTestsCompleted(Uint32.valueOf(tstCompl))
                 .build();
 
-        WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction();
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.OPERATIONAL, TEST_STATUS_IID, status);
 
         try {
@@ -186,11 +181,9 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     }
 
     private void cleanupTestStore() {
-        TestExec data = new TestExecBuilder()
-                .setOuterList(Collections.<OuterList>emptyList())
-                .build();
+        TestExec data = new TestExecBuilder().setOuterList(Collections.emptyMap()).build();
 
-        WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction();
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data);
         try {
             tx.commit().get();
@@ -200,7 +193,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             throw new IllegalStateException(e);
         }
 
-        tx = simpleTxDataBroker.newWriteOnlyTransaction();
+        tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID, data);
         try {
             tx.commit().get();
@@ -228,13 +221,13 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             if (txType == StartTestInput.TransactionType.SIMPLETX) {
                 if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
                     if (StartTestInput.Operation.DELETE == oper) {
-                        retVal = new SimpletxBaDelete(this.simpleTxDataBroker, outerListElem,
+                        retVal = new SimpletxBaDelete(this.dataBroker, outerListElem,
                                 innerListElem,writesPerTx, dataStore);
                     } else if (StartTestInput.Operation.READ == oper) {
-                        retVal = new SimpletxBaRead(this.simpleTxDataBroker, outerListElem,
+                        retVal = new SimpletxBaRead(this.dataBroker, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     } else {
-                        retVal = new SimpletxBaWrite(this.simpleTxDataBroker, oper, outerListElem,
+                        retVal = new SimpletxBaWrite(this.dataBroker, oper, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     }
                 } else {
@@ -252,13 +245,13 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             } else {
                 if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
                     if (StartTestInput.Operation.DELETE == oper) {
-                        retVal = new TxchainBaDelete(this.txChainDataBroker, outerListElem,
+                        retVal = new TxchainBaDelete(this.dataBroker, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     } else if (StartTestInput.Operation.READ == oper) {
-                        retVal = new TxchainBaRead(this.txChainDataBroker,outerListElem,
+                        retVal = new TxchainBaRead(this.dataBroker, outerListElem,
                                 innerListElem,writesPerTx, dataStore);
                     } else {
-                        retVal = new TxchainBaWrite(this.txChainDataBroker, oper, outerListElem,
+                        retVal = new TxchainBaWrite(this.dataBroker, oper, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     }
                 } else {