X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2Fsimpletx%2FSimpletxDomWrite.java;h=181ff23f0b0804e8f71764134ea2e10fa90007aa;hb=refs%2Fchanges%2F14%2F71214%2F13;hp=f367b8359849825130951cd7a7b7b9b5cb4de23f;hpb=29bb6776c62775c5dc73789e4a63d1dc12cc8a64;p=controller.git diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java index f367b83598..181ff23f0b 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java @@ -9,13 +9,12 @@ package org.opendaylight.dsbenchmark.simpletx; import java.util.List; - -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.controller.md.sal.dom.api.DOMDataWriteTransaction; +import java.util.concurrent.ExecutionException; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; import org.opendaylight.dsbenchmark.DomListBuilder; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; +import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; 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; @@ -31,11 +30,11 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter { private final DOMDataBroker domDataBroker; private List list; - public SimpletxDomWrite(DOMDataBroker domDataBroker, StartTestInput.Operation oper, - int outerListElem, int innerListElem, long putsPerTx, DataStore dataStore ) { + public SimpletxDomWrite(final DOMDataBroker domDataBroker, final StartTestInput.Operation oper, + final int outerListElem, final int innerListElem, final long putsPerTx, final DataStore dataStore) { super(oper, outerListElem, innerListElem, putsPerTx, dataStore); this.domDataBroker = domDataBroker; - LOG.info("Created SimpletxDomWrite"); + LOG.debug("Created SimpletxDomWrite"); } @Override @@ -45,26 +44,30 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter { @Override public void executeList() { - DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction(); + final LogicalDatastoreType dsType = getDataStoreType(); + final YangInstanceIdentifier pid = + YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build(); + + DOMDataTreeWriteTransaction tx = domDataBroker.newWriteOnlyTransaction(); long 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++; if (writeCnt == writesPerTx) { try { - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); txError++; } @@ -75,12 +78,10 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter { if (writeCnt != 0) { try { - tx.submit().checkedGet(); - } catch (TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); } } - } - }