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.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.WriteTransaction;
14 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class SimpletxBaDelete extends DatastoreAbstractWriter {
25 private static final Logger LOG = LoggerFactory.getLogger(SimpletxBaDelete.class);
26 private final DataBroker dataBroker;
28 public SimpletxBaDelete(final DataBroker dataBroker, final int outerListElem, final int innerListElem,
29 final long writesPerTx, final DataStore dataStore) {
30 super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
31 this.dataBroker = dataBroker;
32 LOG.debug("Created SimpletxBaDelete");
36 public void createList() {
37 LOG.debug("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,
51 public void executeList() {
52 final LogicalDatastoreType dsType = getDataStoreType();
54 WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
57 for (long l = 0; l < outerListElem; l++) {
58 InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
59 .child(OuterList.class, new OuterListKey((int)l));
60 tx.delete(dsType, iid);
62 if (putCnt == writesPerTx) {
66 } catch (final InterruptedException | ExecutionException e) {
67 LOG.error("Transaction failed", e);
70 tx = dataBroker.newWriteOnlyTransaction();
77 } catch (final InterruptedException | ExecutionException e) {
78 LOG.error("Transaction failed", e);