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
8 package org.opendaylight.dsbenchmark.simpletx;
10 import java.util.concurrent.ExecutionException;
11 import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
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.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
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(final DOMDataBroker domDataBroker, final int outerListElem,
30 final int innerListElem, final long writesPerTx, final DataStore dataStore) {
31 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
32 this.domDataBroker = domDataBroker;
33 LOG.debug("Created simpleTxDomDelete");
37 public void createList() {
38 LOG.debug("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() {
53 final LogicalDatastoreType dsType = getDataStoreType();
54 final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
55 final YangInstanceIdentifier pid =
56 YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
59 DOMDataTreeWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
62 for (int l = 0; l < outerListElem; l++) {
63 YangInstanceIdentifier yid = pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, olId, l));
65 tx.delete(dsType, yid);
67 if (writeCnt == writesPerTx) {
71 } catch (final InterruptedException | ExecutionException e) {
72 LOG.error("Transaction failed", e);
75 tx = domDataBroker.newWriteOnlyTransaction();
82 } catch (final InterruptedException | ExecutionException e) {
83 LOG.error("Transaction failed", e);