Allow DataObjectModification to address grouping nodes
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / simpletx / SimpletxBaDelete.java
index 976623fd99ad3c551f7342a0c9d8436132699004..a165ea0a03b442f1708a0fdecb2a79d403dd49c0 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
@@ -23,57 +24,61 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class SimpletxBaDelete extends DatastoreAbstractWriter {
-    private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxBaDelete.class);
-    private DataBroker dataBroker;
+    private static final Logger LOG = LoggerFactory.getLogger(SimpletxBaDelete.class);
+    private final DataBroker dataBroker;
 
-    public SimpletxBaDelete(DataBroker dataBroker, int outerListElem, int innerListElem, long writesPerTx) {
-        super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+    public SimpletxBaDelete(final DataBroker dataBroker, final int outerListElem, final int innerListElem,
+            final long writesPerTx, final DataStore dataStore) {
+        super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
         this.dataBroker = dataBroker;
-        LOG.info("Created SimpletxBaDelete");
+        LOG.debug("Created SimpletxBaDelete");
     }
 
     @Override
     public void createList() {
-        LOG.info("DatastoreDelete: creating data in the data store");
+        LOG.debug("DatastoreDelete: creating data in the data store");
         // Dump the whole list into the data store in a single transaction
         // with <outerListElem> PUTs on the transaction
         SimpletxBaWrite dd = new SimpletxBaWrite(dataBroker,
                                                  StartTestInput.Operation.PUT,
                                                  outerListElem,
                                                  innerListElem,
-                                                 outerListElem);
+                                                 outerListElem,
+                                                 dataStore);
         dd.createList();
         dd.executeList();
     }
 
     @Override
     public void executeList() {
-            WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
-            long putCnt = 0;
+        final LogicalDatastoreType dsType = getDataStoreType();
+
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        long putCnt = 0;
 
-            for (long l = 0; l < outerListElem; l++) {
-                InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+        for (long l = 0; l < outerListElem; l++) {
+            InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
                                                         .child(OuterList.class, new OuterListKey((int)l));
-                tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
-                putCnt++;
-                if (putCnt == writesPerTx) {
-                    try {
-                        tx.submit().checkedGet();
-                        txOk++;
-                    } catch (TransactionCommitFailedException e) {
-                        LOG.error("Transaction failed: {}", e.toString());
-                        txError++;
-                    }
-                    tx = dataBroker.newWriteOnlyTransaction();
-                    putCnt = 0;
-                }
-            }
-            if (putCnt != 0) {
+            tx.delete(dsType, iid);
+            putCnt++;
+            if (putCnt == writesPerTx) {
                 try {
                     tx.submit().checkedGet();
-                } catch (TransactionCommitFailedException e) {
-                    LOG.error("Transaction failed: {}", e.toString());
+                    txOk++;
+                } catch (final TransactionCommitFailedException e) {
+                    LOG.error("Transaction failed: {}", e);
+                    txError++;
                 }
+                tx = dataBroker.newWriteOnlyTransaction();
+                putCnt = 0;
+            }
+        }
+        if (putCnt != 0) {
+            try {
+                tx.submit().checkedGet();
+            } catch (final TransactionCommitFailedException e) {
+                LOG.error("Transaction failed: {}", e);
             }
+        }
     }
 }