X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2Fsimpletx%2FSimpletxBaWrite.java;h=8893a70574a4ab97e8245d3474edb5c38b7999b7;hb=refs%2Fchanges%2F64%2F84164%2F1;hp=57dd810f000d09ad9c65ff1ddb680f49600d7f8e;hpb=625723b875800d5c421061f09cd5f387ccb59e62;p=controller.git diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java index 57dd810f00..8893a70574 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java @@ -9,13 +9,12 @@ package org.opendaylight.dsbenchmark.simpletx; import java.util.List; - -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.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import java.util.concurrent.ExecutionException; import org.opendaylight.dsbenchmark.BaListBuilder; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +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; @@ -29,11 +28,11 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter { private final DataBroker dataBroker; private List list; - public SimpletxBaWrite(DataBroker dataBroker, StartTestInput.Operation oper, - int outerListElem, int innerListElem, long writesPerTx, DataStore dataStore) { + public SimpletxBaWrite(final DataBroker dataBroker, final StartTestInput.Operation oper, + final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) { super(oper, outerListElem, innerListElem, writesPerTx, dataStore); this.dataBroker = dataBroker; - LOG.info("Created SimpletxBaWrite"); + LOG.debug("Created SimpletxBaWrite"); } @Override @@ -43,14 +42,14 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter { @Override public void executeList() { - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - LogicalDatastoreType dsType = getDataStoreType(); + final LogicalDatastoreType dsType = getDataStoreType(); + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); long writeCnt = 0; for (OuterList element : this.list) { InstanceIdentifier iid = InstanceIdentifier.create(TestExec.class) - .child(OuterList.class, element.getKey()); + .child(OuterList.class, element.key()); if (oper == StartTestInput.Operation.PUT) { tx.put(dsType, iid, element); } else { @@ -61,14 +60,13 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter { if (writeCnt == writesPerTx) { try { - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (TransactionCommitFailedException e) { - LOG.error("Transaction failed: {}", e); + } catch (final InterruptedException | ExecutionException e) { + LOG.error("Transaction failed", e); txError++; } tx = dataBroker.newWriteOnlyTransaction(); - dsType = getDataStoreType(); writeCnt = 0; } @@ -76,9 +74,9 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter { if (writeCnt != 0) { try { - tx.submit().checkedGet(); - } catch (TransactionCommitFailedException e) { - LOG.error("Transaction failed: {}", e); + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { + LOG.error("Transaction failed", e); } } }