2 * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.dsbenchmark.simpletx;
11 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
13 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
14 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
15 import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class SimpletxDomDelete extends DatastoreAbstractWriter {
25 private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxDomDelete.class);
26 private final DOMDataBroker domDataBroker;
28 public SimpletxDomDelete(DOMDataBroker domDataBroker, int outerListElem,
29 int innerListElem, long writesPerTx) {
30 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
31 this.domDataBroker = domDataBroker;
32 LOG.info("Created simpleTxDomDelete");
36 public void createList() {
37 LOG.info("SimpletxDomDelete: creating data in the data store");
38 // Dump the whole list into the data store in a single transaction
39 // with <outerListElem> PUTs on the transaction
40 SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker,
41 StartTestInput.Operation.PUT,
50 public void executeList() {
53 org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
54 DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
56 for (int l = 0; l < outerListElem; l++) {
57 YangInstanceIdentifier yid = YangInstanceIdentifier.builder()
59 .node(OuterList.QNAME)
60 .nodeWithKey(OuterList.QNAME, OL_ID, l)
63 tx.delete(LogicalDatastoreType.CONFIGURATION, yid);
65 if (writeCnt == writesPerTx) {
67 tx.submit().checkedGet();
69 } catch (TransactionCommitFailedException e) {
70 LOG.error("Transaction failed: {}", e.toString());
73 tx = domDataBroker.newWriteOnlyTransaction();
79 tx.submit().checkedGet();
80 } catch (TransactionCommitFailedException e) {
81 LOG.error("Transaction failed: {}", e.toString());