X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2Ftxchain%2FTxchainBaDelete.java;h=bd947acddb13ea595757e72557dac0871f3a1de0;hb=refs%2Fchanges%2F64%2F84164%2F1;hp=bbdb0f56bf45e2d2a59226a45721c9f6ffef847b;hpb=0a786119ca348a347b8a11625804bc1d2e635a49;p=controller.git diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java index bbdb0f56bf..bd947acddb 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java @@ -5,18 +5,19 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.dsbenchmark.txchain; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -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.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.MoreExecutors; +import java.util.concurrent.ExecutionException; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.Transaction; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec; @@ -26,63 +27,59 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; - -public class TxchainBaDelete extends DatastoreAbstractWriter implements TransactionChainListener{ +public class TxchainBaDelete extends DatastoreAbstractWriter implements TransactionChainListener { private static final Logger LOG = LoggerFactory.getLogger(TxchainBaDelete.class); - private DataBroker bindingDataBroker; + private final DataBroker bindingDataBroker; - public TxchainBaDelete(DataBroker bindingDataBroker, int outerListElem, int innerListElem, long writesPerTx, DataStore dataStore) { + public TxchainBaDelete(final DataBroker bindingDataBroker, final int outerListElem, final int innerListElem, + final long writesPerTx, final DataStore dataStore) { super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore); this.bindingDataBroker = bindingDataBroker; - LOG.info("Created TxchainBaDelete"); + LOG.debug("Created TxchainBaDelete"); } @Override public void createList() { - LOG.info("TxchainBaDelete: creating data in the data store"); + LOG.debug("TxchainBaDelete: creating data in the data store"); // Dump the whole list into the data store in a single transaction // with PUTs on the transaction - TxchainBaWrite dd = new TxchainBaWrite(bindingDataBroker, - StartTestInput.Operation.PUT, - outerListElem, - innerListElem, - outerListElem, - dataStore); + TxchainBaWrite dd = new TxchainBaWrite(bindingDataBroker, StartTestInput.Operation.PUT, outerListElem, + innerListElem, outerListElem, dataStore); dd.createList(); dd.executeList(); } @Override public void executeList() { - int txSubmitted = 0; - int writeCnt = 0; + final LogicalDatastoreType dsType = getDataStoreType(); + final TransactionChain chain = bindingDataBroker.createMergingTransactionChain(this); - BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this); WriteTransaction tx = chain.newWriteOnlyTransaction(); + int txSubmitted = 0; + int writeCnt = 0; - for (long l = 0; l < outerListElem; l++) { + for (int l = 0; l < outerListElem; l++) { InstanceIdentifier iid = InstanceIdentifier.create(TestExec.class) - .child(OuterList.class, new OuterListKey((int)l)); - tx.delete(LogicalDatastoreType.CONFIGURATION, iid); + .child(OuterList.class, new OuterListKey(l)); + tx.delete(dsType, iid); writeCnt++; if (writeCnt == writesPerTx) { txSubmitted++; - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { txOk++; } + @Override - public void onFailure(final Throwable t) { - LOG.error("Transaction failed, {}", t); + public void onFailure(final Throwable cause) { + LOG.error("Transaction failed", cause); txError++; } - }); + }, MoreExecutors.directExecutor()); tx = chain.newWriteOnlyTransaction(); writeCnt = 0; } @@ -94,29 +91,26 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact if (writeCnt > 0) { txSubmitted++; } - tx.submit().checkedGet(); - } catch (TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); } try { chain.close(); + } catch (final IllegalStateException e) { + LOG.error("Transaction close failed", e); } - catch (IllegalStateException e){ - LOG.error("Transaction close failed,", e); - } - LOG.info("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError)); + LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError); } @Override - public void onTransactionChainFailed(TransactionChain chain, - AsyncTransaction transaction, Throwable cause) { - LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}", - chain, transaction.getIdentifier(), cause); + public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction, + final Throwable cause) { + LOG.error("Broken chain {} in TxchainBaDelete, transaction {}", chain, transaction.getIdentifier(), cause); } @Override - public void onTransactionChainSuccessful(TransactionChain chain) { - LOG.info("TxchainBaDelete closed successfully, chain {}", chain); + public void onTransactionChainSuccessful(final TransactionChain chain) { + LOG.debug("TxchainBaDelete closed successfully, chain {}", chain); } - }