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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import java.util.Random;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public abstract class DatastoreAbstractWriter {
19 private static final Logger LOG = LoggerFactory.getLogger(DatastoreAbstractWriter.class);
21 protected final int outerListElem;
22 protected final int innerListElem;
23 protected final long writesPerTx;
24 protected final StartTestInput.Operation oper;
25 protected final StartTestInput.DataStore dataStore;
26 protected final Random rn = new Random();
28 protected int txOk = 0;
29 protected int txError = 0;
31 @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "'this' passed to logging")
32 public DatastoreAbstractWriter(final StartTestInput.Operation oper,
33 final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
34 this.outerListElem = outerListElem;
35 this.innerListElem = innerListElem;
36 this.writesPerTx = writesPerTx;
38 this.dataStore = dataStore;
39 LOG.debug("DatastoreAbstractWriter created: {}", this);
42 public abstract void createList();
44 public abstract void executeList();
46 public int getTxError() {
50 public int getTxOk() {
54 protected LogicalDatastoreType getDataStoreType() {
55 final LogicalDatastoreType dsType;
56 if (dataStore == DataStore.CONFIG) {
57 dsType = LogicalDatastoreType.CONFIGURATION;
58 } else if ((dataStore == DataStore.OPERATIONAL) || (rn.nextBoolean() == true)) {
59 dsType = LogicalDatastoreType.OPERATIONAL;
61 dsType = LogicalDatastoreType.CONFIGURATION;