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=14561a58d4a9b602e308b4a9b48cfa044de8846e;hb=466078ab1dc8a8cc2981b161051f6edecd6af85a;hp=a8363df679bfdbb77c60f03c52ad6da9a063d106;hpb=3799d989f25b1f041fa981df7cfc1598b1d129cf;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 a8363df679..14561a58d4 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,20 +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 com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -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.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; @@ -45,12 +44,8 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact // 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(); } @@ -58,7 +53,7 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact @Override public void executeList() { final LogicalDatastoreType dsType = getDataStoreType(); - final BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this); + final TransactionChain chain = bindingDataBroker.createTransactionChain(this); WriteTransaction tx = chain.newWriteOnlyTransaction(); int txSubmitted = 0; @@ -73,18 +68,18 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact 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; } @@ -96,8 +91,8 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact if (writeCnt > 0) { txSubmitted++; } - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); } try { @@ -105,19 +100,18 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact } catch (final IllegalStateException e) { LOG.error("Transaction close failed,", e); } - LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError)); + LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError); } @Override - public void onTransactionChainFailed(final TransactionChain chain, - final AsyncTransaction transaction, final 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 {}, cause {}", chain, transaction.getIdentifier(), + cause); } @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { + public void onTransactionChainSuccessful(final TransactionChain chain) { LOG.debug("TxchainBaDelete closed successfully, chain {}", chain); } - }