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.TestExec;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class SimpletxBaDelete extends DatastoreAbstractWriter {
26 private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxBaDelete.class);
27 private DataBroker dataBroker;
29 public SimpletxBaDelete(DataBroker dataBroker, int outerListElem, int innerListElem, long writesPerTx) {
30 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
31 this.dataBroker = dataBroker;
32 LOG.info("Created SimpletxBaDelete");
36 public void createList() {
37 LOG.info("DatastoreDelete: 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 SimpletxBaWrite dd = new SimpletxBaWrite(dataBroker,
41 StartTestInput.Operation.PUT,
50 public void executeList() {
51 WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
54 for (long l = 0; l < outerListElem; l++) {
55 InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
56 .child(OuterList.class, new OuterListKey((int)l));
57 tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
59 if (putCnt == writesPerTx) {
61 tx.submit().checkedGet();
63 } catch (TransactionCommitFailedException e) {
64 LOG.error("Transaction failed: {}", e.toString());
67 tx = dataBroker.newWriteOnlyTransaction();
73 tx.submit().checkedGet();
74 } catch (TransactionCommitFailedException e) {
75 LOG.error("Transaction failed: {}", e.toString());