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;
10 import java.util.Random;
11 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 public abstract class DatastoreAbstractWriter {
18 private static final Logger LOG = LoggerFactory.getLogger(DatastoreAbstractWriter.class);
20 protected final int outerListElem;
21 protected final int innerListElem;
22 protected final long writesPerTx;
23 protected final StartTestInput.Operation oper;
24 protected final StartTestInput.DataStore dataStore;
25 protected final Random rn = new Random();
27 protected int txOk = 0;
28 protected int txError = 0;
30 public DatastoreAbstractWriter(final StartTestInput.Operation oper,
31 final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
32 this.outerListElem = outerListElem;
33 this.innerListElem = innerListElem;
34 this.writesPerTx = writesPerTx;
36 this.dataStore = dataStore;
37 LOG.debug("DatastoreAbstractWriter created: {}", this);
40 public abstract void createList();
42 public abstract void executeList();
44 public int getTxError() {
48 public int getTxOk() {
52 protected LogicalDatastoreType getDataStoreType() {
53 final LogicalDatastoreType dsType;
54 if (dataStore == DataStore.CONFIG) {
55 dsType = LogicalDatastoreType.CONFIGURATION;
56 } else if (dataStore == DataStore.OPERATIONAL) {
57 dsType = LogicalDatastoreType.OPERATIONAL;
59 if (rn.nextBoolean() == true) {
60 dsType = LogicalDatastoreType.OPERATIONAL;
62 dsType = LogicalDatastoreType.CONFIGURATION;