Adding multiple data store capabilities to the Tx-Chain DOM writer
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / txchain / TxchainDomWrite.java
index f7a44d5f58b36e13106c9da622da552568349f46..97d9222809c9c8dfc923e5e9014fbeb0e67df739 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
 import org.opendaylight.dsbenchmark.DomListBuilder;
 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.data.api.YangInstanceIdentifier;
@@ -38,8 +39,8 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact
     private List<MapEntryNode> list;
 
     public TxchainDomWrite(DOMDataBroker domDataBroker, StartTestInput.Operation oper, int outerListElem,
-            int innerListElem, long writesPerTx) {
-        super(oper, outerListElem, innerListElem, writesPerTx);
+            int innerListElem, long writesPerTx, DataStore dataStore) {
+        super(oper, outerListElem, innerListElem, writesPerTx, dataStore);
         this.domDataBroker = domDataBroker;
         LOG.info("Created TxchainDomWrite");
     }
@@ -55,6 +56,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact
         int writeCnt = 0;
 
         DOMTransactionChain chain = domDataBroker.createTransactionChain(this);
+        LogicalDatastoreType dsType = getDataStoreType();
         DOMDataWriteTransaction tx = chain.newWriteOnlyTransaction();
 
         YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
@@ -62,9 +64,9 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact
             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++;
@@ -83,6 +85,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact
                     }
                 });
                 tx = chain.newWriteOnlyTransaction();
+                dsType = getDataStoreType();
                 writeCnt = 0;
             }
         }
@@ -90,6 +93,7 @@ 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();