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.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class SimpletxDomDelete extends DatastoreAbstractWriter {
27 private static final Logger LOG = LoggerFactory.getLogger(SimpletxDomDelete.class);
28 private final DOMDataBroker domDataBroker;
30 public SimpletxDomDelete(final DOMDataBroker domDataBroker, final int outerListElem,
31 final int innerListElem, final long writesPerTx, final DataStore dataStore) {
32 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
33 this.domDataBroker = domDataBroker;
34 LOG.debug("Created simpleTxDomDelete");
38 public void createList() {
39 LOG.debug("SimpletxDomDelete: creating data in the data store");
40 // Dump the whole list into the data store in a single transaction
41 // with <outerListElem> PUTs on the transaction
42 SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker,
43 StartTestInput.Operation.PUT,
53 public void executeList() {
54 final LogicalDatastoreType dsType = getDataStoreType();
55 final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
56 final YangInstanceIdentifier pid =
57 YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
60 DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
63 for (int l = 0; l < outerListElem; l++) {
64 YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
66 tx.delete(dsType, yid);
68 if (writeCnt == writesPerTx) {
70 tx.submit().checkedGet();
72 } catch (TransactionCommitFailedException e) {
73 LOG.error("Transaction failed: {}", e);
76 tx = domDataBroker.newWriteOnlyTransaction();
82 tx.submit().checkedGet();
83 } catch (TransactionCommitFailedException e) {
84 LOG.error("Transaction failed: {}", e);