X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2FDsbenchmarkProvider.java;h=c5232a2b79f6fbef55d5df02ad7bf55e33dad652;hp=160f4888d096365c6dd8f3c4d9d160056baee10e;hb=0b283e62a5872be1960635d5d6c4d301b1f87df2;hpb=258d8039ac144aeee2efa7943228c0fc6cdaf651 diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java index 160f4888d0..c5232a2b79 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java @@ -10,12 +10,8 @@ package org.opendaylight.dsbenchmark; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collections; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicReference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.dsbenchmark.listener.DsbenchmarkListenerProvider; import org.opendaylight.dsbenchmark.simpletx.SimpletxBaDelete; import org.opendaylight.dsbenchmark.simpletx.SimpletxBaRead; @@ -29,6 +25,10 @@ import org.opendaylight.dsbenchmark.txchain.TxchainBaWrite; import org.opendaylight.dsbenchmark.txchain.TxchainDomDelete; import org.opendaylight.dsbenchmark.txchain.TxchainDomRead; import org.opendaylight.dsbenchmark.txchain.TxchainDomWrite; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.CleanupStoreInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.CleanupStoreOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.CleanupStoreOutputBuilder; @@ -59,22 +59,18 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { private final AtomicReference 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. @@ -100,6 +96,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { } @Override + @SuppressWarnings("checkstyle:illegalCatch") public ListenableFuture> startTest(final StartTestInput input) { LOG.info("Starting the data store benchmark test, input: {}", input); @@ -120,14 +117,14 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { // Create listeners on OPERATIONAL and CONFIG test data subtrees listenerProvider.createAndRegisterListeners(input.getListeners().intValue()); - long startTime, endTime, listCreateTime, execTime; - startTime = System.nanoTime(); + long startTime = System.nanoTime(); dsWriter.createList(); - endTime = System.nanoTime(); - listCreateTime = (endTime - startTime) / 1000; + long endTime = System.nanoTime(); + final long listCreateTime = (endTime - startTime) / 1000; // Run the test and measure the execution time + long execTime; try { startTime = System.nanoTime(); dsWriter.executeList(); @@ -171,12 +168,12 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { .setTestsCompleted(tstCompl) .build(); - WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction(); + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.OPERATIONAL, TEST_STATUS_IID, status); try { - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { throw new IllegalStateException(e); } @@ -188,22 +185,22 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { .setOuterList(Collections.emptyList()) .build(); - WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction(); + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data); try { - tx.submit().checkedGet(); + tx.commit().get(); LOG.debug("DataStore config test data cleaned up"); - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.info("Failed to cleanup DataStore configtest data"); throw new IllegalStateException(e); } - tx = simpleTxDataBroker.newWriteOnlyTransaction(); + tx = dataBroker.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID, data); try { - tx.submit().checkedGet(); + tx.commit().get(); LOG.debug("DataStore operational test data cleaned up"); - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.info("Failed to cleanup DataStore operational test data"); throw new IllegalStateException(e); } @@ -226,13 +223,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 { @@ -250,13 +247,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 {