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;
11 import java.util.Random;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public abstract class DatastoreAbstractWriter {
20 private static final Logger LOG = LoggerFactory.getLogger(DatastoreAbstractWriter.class);
22 protected final int outerListElem;
23 protected final int innerListElem;
24 protected final long writesPerTx;
25 protected final StartTestInput.Operation oper;
26 protected final StartTestInput.DataStore dataStore;
27 protected final Random rn = new Random();
30 protected int txOk = 0;
31 protected int txError = 0;
34 public DatastoreAbstractWriter(final StartTestInput.Operation oper,
35 final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
36 this.outerListElem = outerListElem;
37 this.innerListElem = innerListElem;
38 this.writesPerTx = writesPerTx;
40 this.dataStore = dataStore;
41 LOG.debug("DatastoreAbstractWriter created: {}", this);
44 public abstract void createList();
46 public abstract void executeList();
48 public int getTxError() {
52 public int getTxOk() {
56 protected LogicalDatastoreType getDataStoreType() {
57 final LogicalDatastoreType dsType;
58 if (dataStore == DataStore.CONFIG) {
59 dsType = LogicalDatastoreType.CONFIGURATION;
60 } else if (dataStore == DataStore.OPERATIONAL) {
61 dsType = LogicalDatastoreType.OPERATIONAL;
63 if (rn.nextBoolean() == true) {
64 dsType = LogicalDatastoreType.OPERATIONAL;
66 dsType = LogicalDatastoreType.CONFIGURATION;