package org.opendaylight.dsbenchmark.simpletx;
+import java.util.concurrent.ExecutionException;
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 org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(SimpletxDomDelete.class);
private final DOMDataBroker domDataBroker;
- public SimpletxDomDelete(DOMDataBroker domDataBroker, int outerListElem,
- int innerListElem, long writesPerTx, DataStore dataStore) {
+ public SimpletxDomDelete(final DOMDataBroker domDataBroker, final int outerListElem,
+ final int innerListElem, final long writesPerTx, final DataStore dataStore) {
super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
this.domDataBroker = domDataBroker;
- LOG.info("Created simpleTxDomDelete");
+ LOG.debug("Created simpleTxDomDelete");
}
@Override
public void createList() {
- LOG.info("SimpletxDomDelete: creating data in the data store");
+ LOG.debug("SimpletxDomDelete: creating data in the data store");
// Dump the whole list into the data store in a single transaction
// with <outerListElem> PUTs on the transaction
SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker,
@Override
public void executeList() {
- long writeCnt = 0;
+ final LogicalDatastoreType dsType = getDataStoreType();
+ final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
+ final YangInstanceIdentifier pid =
+ YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
+
- org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
+ long writeCnt = 0;
for (int l = 0; l < outerListElem; l++) {
- YangInstanceIdentifier yid = YangInstanceIdentifier.builder()
- .node(TestExec.QNAME)
- .node(OuterList.QNAME)
- .nodeWithKey(OuterList.QNAME, olId, l)
- .build();
+ YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
- tx.delete(LogicalDatastoreType.CONFIGURATION, yid);
+ tx.delete(dsType, yid);
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++;
}
}
if (writeCnt != 0) {
try {
- tx.submit().checkedGet();
- } catch (TransactionCommitFailedException e) {
+ tx.commit().get();
+ } catch (final InterruptedException | ExecutionException e) {
LOG.error("Transaction failed: {}", e);
}
}