X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2Ftxchain%2FTxchainBaWrite.java;h=a0327a97029d2a4c0dbe68088bcf2bdd56d6afe6;hp=3c78de4b1adb3e64615707f9365ad9aee6b6465c;hb=3799d989f25b1f041fa981df7cfc1598b1d129cf;hpb=bc740310bca93dcefcf546f7c4a627d8153b3739 diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java index 3c78de4b1a..a0327a9702 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java @@ -8,8 +8,9 @@ package org.opendaylight.dsbenchmark.txchain; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; import java.util.List; - 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; @@ -20,27 +21,25 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListen import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.dsbenchmark.BaListBuilder; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.Operation; 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.StartTestInput.Operation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec; 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.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; - public class TxchainBaWrite extends DatastoreAbstractWriter implements TransactionChainListener { private static final Logger LOG = LoggerFactory.getLogger(TxchainBaWrite.class); private final DataBroker bindingDataBroker; private List list; - public TxchainBaWrite(DataBroker bindingDataBroker, Operation oper, - int outerListElem, int innerListElem, long writesPerTx) { - super(oper, outerListElem, innerListElem, writesPerTx); + public TxchainBaWrite(final DataBroker bindingDataBroker, final Operation oper, + final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) { + super(oper, outerListElem, innerListElem, writesPerTx, dataStore); this.bindingDataBroker = bindingDataBroker; - LOG.info("Created TxchainBaWrite"); + LOG.debug("Created TxchainBaWrite"); } @Override @@ -50,19 +49,21 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti @Override public void executeList() { - int txSubmitted = 0; - int writeCnt = 0; + final BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this); + final LogicalDatastoreType dsType = getDataStoreType(); - BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this); WriteTransaction tx = chain.newWriteOnlyTransaction(); + int txSubmitted = 0; + int writeCnt = 0; for (OuterList element : this.list) { InstanceIdentifier iid = InstanceIdentifier.create(TestExec.class) .child(OuterList.class, element.getKey()); + if (oper == StartTestInput.Operation.PUT) { - tx.put(LogicalDatastoreType.CONFIGURATION, iid, element); + tx.put(dsType, iid, element); } else { - tx.merge(LogicalDatastoreType.CONFIGURATION, iid, element); + tx.merge(dsType, iid, element); } writeCnt++; @@ -74,6 +75,7 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti public void onSuccess(final Void result) { txOk++; } + @Override public void onFailure(final Throwable t) { LOG.error("Transaction failed, {}", t); @@ -92,29 +94,28 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti txSubmitted++; tx.submit().checkedGet(); txOk++; - } catch (TransactionCommitFailedException e) { + } catch (final TransactionCommitFailedException e) { LOG.error("Transaction failed", e); txError++; } try { chain.close(); - } - catch (IllegalStateException e){ + } catch (final 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) { + public void onTransactionChainFailed(final TransactionChain chain, + final AsyncTransaction transaction, final Throwable cause) { LOG.error("Broken chain {} in DatastoreBaAbstractWrite, transaction {}, cause {}", chain, transaction.getIdentifier(), cause); } @Override - public void onTransactionChainSuccessful(TransactionChain chain) { - LOG.info("DatastoreBaAbstractWrite closed successfully, chain {}", chain); + public void onTransactionChainSuccessful(final TransactionChain chain) { + LOG.debug("DatastoreBaAbstractWrite closed successfully, chain {}", chain); } } \ No newline at end of file