X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=benchmark%2Fdsbenchmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fdsbenchmark%2Fsimpletx%2FSimpletxDomDelete.java;h=4f29cdceab0b342aadefe9e153f0bdee9939e7db;hp=ab7590cdac6b65eb048412d99b6a3cd60315cfd9;hb=842ae4586043f7a230ab701696e4e4f0b7ff49f4;hpb=bc740310bca93dcefcf546f7c4a627d8153b3739 diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java index ab7590cdac..4f29cdceab 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java @@ -5,69 +5,71 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.dsbenchmark.simpletx; -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 java.util.concurrent.ExecutionException; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; +import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; 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.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; public class SimpletxDomDelete extends DatastoreAbstractWriter { - private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxDomDelete.class); + private static final Logger LOG = LoggerFactory.getLogger(SimpletxDomDelete.class); private final DOMDataBroker domDataBroker; - public SimpletxDomDelete(DOMDataBroker domDataBroker, int outerListElem, - int innerListElem, long writesPerTx) { - super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx); + 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 PUTs on the transaction SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker, StartTestInput.Operation.PUT, outerListElem, innerListElem, - outerListElem); + outerListElem, + dataStore); dd.createList(); dd.executeList(); } @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 OL_ID = QName.create(OuterList.QNAME, "id"); - DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction(); + DOMDataTreeWriteTransaction 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, OL_ID, l) - .build(); + YangInstanceIdentifier yid = pid.node(NodeIdentifierWithPredicates.of(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) { - LOG.error("Transaction failed: {}", e.toString()); + } catch (final InterruptedException | ExecutionException e) { + LOG.error("Transaction failed", e); txError++; } tx = domDataBroker.newWriteOnlyTransaction(); @@ -76,9 +78,9 @@ public class SimpletxDomDelete extends DatastoreAbstractWriter { } if (writeCnt != 0) { try { - tx.submit().checkedGet(); - } catch (TransactionCommitFailedException e) { - LOG.error("Transaction failed: {}", e.toString()); + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { + LOG.error("Transaction failed", e); } } }