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.StartTestInput.DataStore;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class SimpletxDomDelete extends DatastoreAbstractWriter {
26 private static final Logger LOG = LoggerFactory.getLogger(SimpletxDomDelete.class);
27 private final DOMDataBroker domDataBroker;
29 public SimpletxDomDelete(DOMDataBroker domDataBroker, int outerListElem,
30 int innerListElem, long writesPerTx, DataStore dataStore) {
31 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
32 this.domDataBroker = domDataBroker;
33 LOG.info("Created simpleTxDomDelete");
37 public void createList() {
38 LOG.info("SimpletxDomDelete: creating data in the data store");
39 // Dump the whole list into the data store in a single transaction
40 // with <outerListElem> PUTs on the transaction
41 SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker,
42 StartTestInput.Operation.PUT,
52 public void executeList() {
55 org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
56 DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
58 for (int l = 0; l < outerListElem; l++) {
59 YangInstanceIdentifier yid = YangInstanceIdentifier.builder()
61 .node(OuterList.QNAME)
62 .nodeWithKey(OuterList.QNAME, olId, l)
65 tx.delete(LogicalDatastoreType.CONFIGURATION, yid);
67 if (writeCnt == writesPerTx) {
69 tx.submit().checkedGet();
71 } catch (TransactionCommitFailedException e) {
72 LOG.error("Transaction failed: {}", e);
75 tx = domDataBroker.newWriteOnlyTransaction();
81 tx.submit().checkedGet();
82 } catch (TransactionCommitFailedException e) {
83 LOG.error("Transaction failed: {}", e);