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;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
16 import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class SimpletxBaDelete extends DatastoreAbstractWriter {
27 private static final Logger LOG = LoggerFactory.getLogger(SimpletxBaDelete.class);
28 private final DataBroker dataBroker;
30 public SimpletxBaDelete(final DataBroker dataBroker, final int outerListElem, final int innerListElem,
31 final long writesPerTx, final DataStore dataStore) {
32 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
33 this.dataBroker = dataBroker;
34 LOG.debug("Created SimpletxBaDelete");
38 public void createList() {
39 LOG.debug("DatastoreDelete: 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 SimpletxBaWrite dd = new SimpletxBaWrite(dataBroker,
43 StartTestInput.Operation.PUT,
53 public void executeList() {
54 final LogicalDatastoreType dsType = getDataStoreType();
56 WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
59 for (long l = 0; l < outerListElem; l++) {
60 InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
61 .child(OuterList.class, new OuterListKey((int)l));
62 tx.delete(dsType, iid);
64 if (putCnt == writesPerTx) {
66 tx.submit().checkedGet();
68 } catch (TransactionCommitFailedException e) {
69 LOG.error("Transaction failed: {}", e);
72 tx = dataBroker.newWriteOnlyTransaction();
78 tx.submit().checkedGet();
79 } catch (TransactionCommitFailedException e) {
80 LOG.error("Transaction failed: {}", e);