X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2Ftxchain%2FTxchainDomWrite.java;h=52f574ab1c0ecf240b20378fbccb5dd434aead9b;hb=f9814cf027886294b74fb6c8748f4a3e0a545e86;hp=902397c3b5a9776c5e8bcbe5df80bcb86f6a18e1;hpb=29bb6776c62775c5dc73789e4a63d1dc12cc8a64;p=controller.git diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java index 902397c3b5..52f574ab1c 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.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.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; @@ -30,19 +31,16 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; - public class TxchainDomWrite extends DatastoreAbstractWriter implements TransactionChainListener { private static final Logger LOG = LoggerFactory.getLogger(TxchainDomWrite.class); private final DOMDataBroker domDataBroker; private List list; - public TxchainDomWrite(DOMDataBroker domDataBroker, StartTestInput.Operation oper, int outerListElem, - int innerListElem, long writesPerTx, DataStore dataStore) { + public TxchainDomWrite(final DOMDataBroker domDataBroker, final StartTestInput.Operation oper, final int outerListElem, + final int innerListElem, final long writesPerTx, final DataStore dataStore) { super(oper, outerListElem, innerListElem, writesPerTx, dataStore); this.domDataBroker = domDataBroker; - LOG.info("Created TxchainDomWrite"); + LOG.debug("Created TxchainDomWrite"); } @Override @@ -52,24 +50,28 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact @Override public void executeList() { - int txSubmitted = 0; - int writeCnt = 0; + final LogicalDatastoreType dsType = getDataStoreType(); + final YangInstanceIdentifier pid = + YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build(); + final DOMTransactionChain chain = domDataBroker.createTransactionChain(this); - DOMTransactionChain chain = domDataBroker.createTransactionChain(this); DOMDataWriteTransaction tx = chain.newWriteOnlyTransaction(); + int txSubmitted = 0; + int writeCnt = 0; - YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build(); for (MapEntryNode element : this.list) { - YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues())); + YangInstanceIdentifier yid = + pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues())); if (oper == StartTestInput.Operation.PUT) { - tx.put(LogicalDatastoreType.CONFIGURATION, yid, element); + tx.put(dsType, yid, element); } else { - tx.merge(LogicalDatastoreType.CONFIGURATION, yid, element); + tx.merge(dsType, yid, element); } writeCnt++; + // Start performing the operation; submit the transaction at every n-th operation if (writeCnt == writesPerTx) { txSubmitted++; Futures.addCallback(tx.submit(), new FutureCallback() { @@ -77,6 +79,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact public void onSuccess(final Void result) { txOk++; } + @Override public void onFailure(final Throwable t) { LOG.error("Transaction failed, {}", t); @@ -91,33 +94,34 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact // *** Clean up and close the transaction chain *** // Submit the outstanding transaction even if it's empty and wait for it to finish // We need to empty the transaction chain before closing it + try { 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 TxchainDomWrite, transaction {}, cause {}", chain, transaction.getIdentifier(), cause); } @Override - public void onTransactionChainSuccessful(TransactionChain chain) { - LOG.info("Chain {} closed successfully", chain); + public void onTransactionChainSuccessful(final TransactionChain chain) { + LOG.debug("Chain {} closed successfully", chain); } }