BUG-7390: fix dsbenchmark
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / simpletx / SimpletxBaWrite.java
index f811c4b6b63160e41d7065c50d3743620f914728..046ac75cea56a0ee59ec80378ba7341487a2066d 100644 (file)
@@ -9,7 +9,6 @@
 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;
@@ -17,6 +16,7 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 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;
+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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -28,20 +28,22 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter {
     private final DataBroker dataBroker;
     private List<OuterList> list;
 
-    public SimpletxBaWrite(DataBroker dataBroker, StartTestInput.Operation oper,
-            int outerListElem, int innerListElem, long writesPerTx) {
-        super(oper, outerListElem, innerListElem, writesPerTx);
+    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");
     }
 
-     @Override
-     public void createList() {
-         list = BaListBuilder.buildOuterList(this.outerListElem, this.innerListElem);
-     }
+    @Override
+    public void createList() {
+        list = BaListBuilder.buildOuterList(this.outerListElem, this.innerListElem);
+    }
 
     @Override
     public void executeList() {
+        final LogicalDatastoreType dsType = getDataStoreType();
+
         WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         long writeCnt = 0;
 
@@ -49,9 +51,9 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter {
             InstanceIdentifier<OuterList> 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++;
@@ -61,10 +63,11 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter {
                     tx.submit().checkedGet();
                     txOk++;
                 } catch (TransactionCommitFailedException e) {
-                    LOG.error("Transaction failed: {}", e.toString());
+                    LOG.error("Transaction failed: {}", e);
                     txError++;
                 }
                 tx = dataBroker.newWriteOnlyTransaction();
+
                 writeCnt = 0;
             }
         }
@@ -73,7 +76,7 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter {
             try {
                 tx.submit().checkedGet();
             } catch (TransactionCommitFailedException e) {
-                LOG.error("Transaction failed: {}", e.toString());
+                LOG.error("Transaction failed: {}", e);
             }
         }
     }