--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>benchmark-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+</project>
--- /dev/null
+module dsbenchmark {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:dsbenchmark";
+ prefix "dsbenchmark";
+
+ revision "2015-01-05" {
+ description "Initial revision of dsbenchmark model";
+ }
+ container test-exec {
+ config true;
+
+ list outer-list {
+ key id;
+ leaf id {
+ type int32;
+ }
+ choice outer-choice {
+ case one {
+ leaf one {
+ type string;
+ }
+ }
+ case two-three {
+ leaf two {
+ type string;
+ }
+ leaf three {
+ type string;
+ }
+ }
+ }
+ list inner-list {
+ key name;
+ leaf name {
+ type int32;
+ }
+ leaf value {
+ type string;
+ }
+ }
+ }
+ }
+
+ container test-status {
+ leaf execStatus {
+ type enumeration {
+ enum "idle" {
+ value 1;
+ }
+ enum "executing" {
+ value 2;
+ }
+ }
+ config false;
+ mandatory true;
+ description
+ "Indicates whether a test run is in progress; only one test can run at a time";
+ }
+ leaf testsCompleted {
+ type uint32;
+ default 1;
+ description
+ "Number of completed test runs";
+ }
+ }
+
+ rpc start-test {
+ description
+ "Start a new data store write test run";
+
+ input {
+ leaf operation {
+ mandatory true;
+ type enumeration {
+ enum "PUT" {
+ value 1;
+ description
+ "The put operation";
+ }
+ enum "MERGE" {
+ value 2;
+ description
+ "The merge operation";
+ }
+ enum "DELETE" {
+ value 3;
+ description
+ "Delete items from a list sotred in the data store";
+ }
+ enum "READ" {
+ value 4;
+ description
+ "The read operation";
+ }
+ }
+ description
+ "Type of the transaction operation to benchmark";
+ }
+
+ leaf data-format {
+ mandatory true;
+ type enumeration {
+ enum "BINDING-AWARE" {
+ value 1;
+ }
+ enum "BINDING-INDEPENDENT" {
+ value 2;
+ }
+ }
+ description
+ "Data format:-binding-aware or binding-independent";
+ }
+
+ leaf transaction-type {
+ mandatory true;
+ type enumeration {
+ enum "SIMPLE-TX" {
+ value 1;
+ }
+ enum "TX-CHAINING" {
+ value 2;
+ }
+ }
+ description
+ "Data format:-binding-aware or binding-independent";
+ }
+
+ leaf outerElements {
+ type uint32;
+ default 100000;
+ description
+ "Number of elements in the OuterList";
+ }
+ leaf innerElements {
+ type uint32;
+ default 1;
+ description
+ "Number of elements in the InnerList";
+ }
+ leaf putsPerTx {
+ type uint32;
+ default 1;
+ description
+ "Number of write operations (PUT, MERGE, or DELETE) per transaction submit";
+ }
+ }
+ output {
+ leaf status {
+ mandatory true;
+ type enumeration {
+ enum "OK" {
+ value 1;
+ }
+ enum "FAILED" {
+ value 2;
+ }
+ enum "TEST-IN-PROGRESS" {
+ value 3;
+ }
+ }
+ description
+ "Indicates whether the test finished successfuly";
+ }
+ leaf listBuildTime {
+ type uint32;
+ default 1;
+ description
+ "The time it took to build the list of lists";
+ }
+ leaf execTime {
+ type uint32;
+ default 1;
+ description
+ "The time it took to execute all transactions";
+ }
+ leaf txOk {
+ type uint32;
+ default 1;
+ description
+ "The number of successful transactions";
+ }
+ leaf txError {
+ type uint32;
+ default 1;
+ description
+ "The number of failed transactions";
+ }
+
+ }
+ }
+
+ rpc cleanup-store {
+ description
+ "Delete data in the test-exec container that may have been left behind from a previous test run";
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>benchmark-artifacts</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>benchmark-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>dsbenchmark</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>benchmark-features</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>dsbenchmark</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>benchmark-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-impl</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<snapshot>
+ <required-capabilities>
+ <capability>urn:opendaylight:params:xml:ns:yang:dsbenchmark:impl?module=dsbenchmark-impl&revision=2014-12-10</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
+ </required-capabilities>
+ <configuration>
+
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:dsbenchmark:impl">prefix:dsbenchmark-impl</type>
+ <name>dsbenchmark-default</name>
+ <broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+ <name>binding-osgi-broker</name>
+ </broker>
+ <dom-data-broker>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <name>pingpong-broker</name>
+ </dom-data-broker>
+ <binding-data-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>pingpong-binding-data-broker</name>
+ </binding-data-broker>
+ </module>
+ </modules>
+ </data>
+ </configuration>
+</snapshot>
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListKey;
+
+public final class BaListBuilder {
+ static public List<OuterList> buildOuterList(int outerElements, int innerElements) {
+ List<OuterList> outerList = new ArrayList<OuterList>(outerElements);
+ for (int j = 0; j < outerElements; j++) {
+ outerList.add(new OuterListBuilder()
+ .setId( j )
+ .setInnerList(buildInnerList(j, innerElements))
+ .setKey(new OuterListKey( j ))
+ .build());
+ }
+
+ return outerList;
+ }
+
+ static private List<InnerList> buildInnerList( int index, int elements ) {
+ List<InnerList> innerList = new ArrayList<InnerList>( elements );
+
+ final String itemStr = "Item-" + String.valueOf(index) + "-";
+ for( int i = 0; i < elements; i++ ) {
+ innerList.add(new InnerListBuilder()
+ .setKey( new InnerListKey( i ) )
+ .setName(i)
+ .setValue( itemStr + String.valueOf( i ) )
+ .build());
+ }
+
+ return innerList;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+
+public abstract class DatastoreAbstractWriter {
+ protected final int outerListElem;
+ protected final int innerListElem;
+ protected final long writesPerTx;
+ protected final StartTestInput.Operation oper;
+
+ protected int txOk = 0;
+ protected int txError = 0;
+
+
+ public DatastoreAbstractWriter(StartTestInput.Operation oper,
+ int outerListElem, int innerListElem, long writesPerTx) {
+ this.outerListElem = outerListElem;
+ this.innerListElem = innerListElem;
+ this.writesPerTx = writesPerTx;
+ this.oper = oper;
+ }
+
+ public abstract void createList();
+ public abstract void executeList();
+
+ public int getTxError() {
+ return txError;
+ }
+
+ public int getTxOk() {
+ return txOk;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
+
+public final class DomListBuilder {
+ // Inner List Qname identifiers for yang model's 'name' and 'value'
+ private static final org.opendaylight.yangtools.yang.common.QName IL_NAME = QName.create(InnerList.QNAME, "name");
+ private static final org.opendaylight.yangtools.yang.common.QName IL_VALUE = QName.create(InnerList.QNAME, "value");
+
+ // Outer List Qname identifier for yang model's 'id'
+ private static final org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
+
+ static public List<MapEntryNode> buildOuterList(int outerElements, int innerElements) {
+ List<MapEntryNode> outerList = new ArrayList<MapEntryNode>(outerElements);
+ for (int j = 0; j < outerElements; j++) {
+ outerList.add(ImmutableNodes.mapEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifierWithPredicates(OuterList.QNAME, OL_ID, j))
+ .withChild(ImmutableNodes.leafNode(OL_ID, j))
+ .withChild(buildInnerList(j, innerElements))
+ .build());
+ }
+
+ return outerList;
+ }
+
+ static private MapNode buildInnerList(int index, int elements ) {
+ CollectionNodeBuilder<MapEntryNode, MapNode> innerList = ImmutableNodes.mapNodeBuilder(InnerList.QNAME);
+
+ final String itemStr = "Item-" + String.valueOf(index) + "-";
+ for( int i = 0; i < elements; i++ ) {
+ innerList.addChild(ImmutableNodes.mapEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifierWithPredicates(InnerList.QNAME, IL_NAME, i))
+ .withChild(ImmutableNodes.leafNode(IL_NAME, i))
+ .withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i)))
+ .build());
+ }
+ return innerList.build();
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.dsbenchmark;
+
+import java.util.Collections;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.dsbenchmark.simpletx.SimpletxBaDelete;
+import org.opendaylight.dsbenchmark.simpletx.SimpletxBaRead;
+import org.opendaylight.dsbenchmark.simpletx.SimpletxBaWrite;
+import org.opendaylight.dsbenchmark.simpletx.SimpletxDomDelete;
+import org.opendaylight.dsbenchmark.simpletx.SimpletxDomRead;
+import org.opendaylight.dsbenchmark.simpletx.SimpletxDomWrite;
+import org.opendaylight.dsbenchmark.txchain.TxchainBaDelete;
+import org.opendaylight.dsbenchmark.txchain.TxchainBaRead;
+import org.opendaylight.dsbenchmark.txchain.TxchainBaWrite;
+import org.opendaylight.dsbenchmark.txchain.TxchainDomDelete;
+import org.opendaylight.dsbenchmark.txchain.TxchainDomRead;
+import org.opendaylight.dsbenchmark.txchain.TxchainDomWrite;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.DsbenchmarkService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExecBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatus.ExecStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatusBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.Futures;
+
+public class DsbenchmarkProvider implements BindingAwareProvider, DsbenchmarkService, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DsbenchmarkProvider.class);
+ private final AtomicReference<ExecStatus> execStatus = new AtomicReference<ExecStatus>( ExecStatus.Idle );
+
+ private static final InstanceIdentifier<TestExec> TEST_EXEC_IID = InstanceIdentifier.builder(TestExec.class).build();
+ private static final InstanceIdentifier<TestStatus> TEST_STATUS_IID = InstanceIdentifier.builder(TestStatus.class).build();
+ private final DOMDataBroker domDataBroker;
+ private final DataBroker bindingDataBroker;
+ private RpcRegistration<DsbenchmarkService> dstReg;
+ private DataBroker dataBroker;
+
+ private long testsCompleted = 0;
+
+ public DsbenchmarkProvider(DOMDataBroker domDataBroker, DataBroker bindingDataBroker) {
+ // We have to get the DOMDataBroker via the constructor,
+ // since we can't get it from the session
+ this.domDataBroker = domDataBroker;
+ this.bindingDataBroker = bindingDataBroker;
+ }
+
+ @Override
+ public void onSessionInitiated(ProviderContext session) {
+ this.dataBroker = session.getSALService(DataBroker.class);
+ this.dstReg = session.addRpcImplementation( DsbenchmarkService.class, this );
+ setTestOperData(this.execStatus.get(), testsCompleted);
+
+ LOG.info("DsbenchmarkProvider Session Initiated");
+ }
+
+ @Override
+ public void close() throws Exception {
+ dstReg.close();
+ LOG.info("DsbenchmarkProvider Closed");
+ }
+
+ @Override
+ public Future<RpcResult<Void>> cleanupStore() {
+ cleanupTestStore();
+ LOG.info("Data Store cleaned up");
+ return Futures.immediateFuture( RpcResultBuilder.<Void> success().build() );
+ }
+
+ @Override
+ public Future<RpcResult<StartTestOutput>> startTest(StartTestInput input) {
+ LOG.info("Starting the data store benchmark test, input: {}", input);
+
+ // Check if there is a test in progress
+ if ( execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing) == false ) {
+ LOG.info("Test in progress");
+ return RpcResultBuilder.success(new StartTestOutputBuilder()
+ .setStatus(StartTestOutput.Status.TESTINPROGRESS)
+ .build()).buildFuture();
+ }
+
+ // Cleanup data that may be left over from a previous test run
+ cleanupTestStore();
+
+ // Get the appropriate writer based on operation type and data format
+ DatastoreAbstractWriter dsWriter = getDatastoreWriter(input);
+
+ long startTime, endTime, listCreateTime, execTime;
+
+ startTime = System.nanoTime();
+ dsWriter.createList();
+ endTime = System.nanoTime();
+ listCreateTime = (endTime - startTime) / 1000;
+
+ // Run the test and measure the execution time
+ try {
+ startTime = System.nanoTime();
+ dsWriter.executeList();
+ endTime = System.nanoTime();
+ execTime = (endTime - startTime) / 1000;
+
+ this.testsCompleted++;
+
+ } catch ( Exception e ) {
+ LOG.error( "Test error: {}", e.toString());
+ execStatus.set( ExecStatus.Idle );
+ return RpcResultBuilder.success(new StartTestOutputBuilder()
+ .setStatus(StartTestOutput.Status.FAILED)
+ .build()).buildFuture();
+ }
+
+ LOG.info("Test finished");
+ setTestOperData( ExecStatus.Idle, testsCompleted);
+ execStatus.set(ExecStatus.Idle);
+
+ StartTestOutput output = new StartTestOutputBuilder()
+ .setStatus(StartTestOutput.Status.OK)
+ .setListBuildTime(listCreateTime)
+ .setExecTime(execTime)
+ .setTxOk((long)dsWriter.getTxOk())
+ .setTxError((long)dsWriter.getTxError())
+ .build();
+
+ return RpcResultBuilder.success(output).buildFuture();
+ }
+
+ private void setTestOperData( ExecStatus sts, long tstCompl ) {
+ TestStatus status = new TestStatusBuilder()
+ .setExecStatus(sts)
+ .setTestsCompleted(tstCompl)
+ .build();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.put(LogicalDatastoreType.OPERATIONAL, TEST_STATUS_IID, status);
+
+ try {
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ throw new IllegalStateException(e);
+ }
+
+ LOG.info("DataStore test oper status populated: {}", status);
+ }
+
+ private void cleanupTestStore() {
+ TestExec data = new TestExecBuilder()
+ .setOuterList(Collections.<OuterList>emptyList())
+ .build();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data);
+ try {
+ tx.submit().checkedGet();
+ LOG.info("DataStore test data cleaned up");
+ } catch (TransactionCommitFailedException e) {
+ LOG.info("Failed to cleanup DataStore test data");
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ private DatastoreAbstractWriter getDatastoreWriter(StartTestInput input) {
+
+ final DatastoreAbstractWriter retVal;
+
+ StartTestInput.TransactionType txType = input.getTransactionType();
+ StartTestInput.Operation oper = input.getOperation();
+ StartTestInput.DataFormat dataFormat = input.getDataFormat();
+ int outerListElem = input.getOuterElements().intValue();
+ int innerListElem = input.getInnerElements().intValue();
+ int writesPerTx = input.getPutsPerTx().intValue();
+
+ try {
+ if (txType == StartTestInput.TransactionType.SIMPLETX) {
+ if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
+ if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new SimpletxBaDelete(this.dataBroker, outerListElem,
+ innerListElem,writesPerTx);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new SimpletxBaRead(this.dataBroker, outerListElem,
+ innerListElem,writesPerTx);
+ } else {
+ retVal = new SimpletxBaWrite(this.dataBroker, oper, outerListElem,
+ innerListElem,writesPerTx);
+ }
+ } else {
+ if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new SimpletxDomDelete(this.domDataBroker, outerListElem,
+ innerListElem, writesPerTx);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new SimpletxDomRead(this.domDataBroker, outerListElem,
+ innerListElem, writesPerTx);
+ } else {
+ retVal = new SimpletxDomWrite(this.domDataBroker, oper, outerListElem,
+ innerListElem,writesPerTx);
+ }
+ }
+ } else {
+ if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
+ if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new TxchainBaDelete(this.bindingDataBroker, outerListElem,
+ innerListElem, writesPerTx);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new TxchainBaRead(this.bindingDataBroker,outerListElem,
+ innerListElem,writesPerTx);
+ } else {
+ retVal = new TxchainBaWrite(this.bindingDataBroker, oper, outerListElem,
+ innerListElem,writesPerTx);
+ }
+ } else {
+ if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new TxchainDomDelete(this.domDataBroker, outerListElem,
+ innerListElem, writesPerTx);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new TxchainDomRead(this.domDataBroker, outerListElem,
+ innerListElem, writesPerTx);
+
+ } else {
+ retVal = new TxchainDomWrite(this.domDataBroker, oper, outerListElem,
+ innerListElem,writesPerTx);
+ }
+ }
+ }
+ } finally {
+ execStatus.set(ExecStatus.Idle);
+ }
+ return retVal;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.simpletx;
+
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SimpletxBaDelete extends DatastoreAbstractWriter {
+ private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxBaDelete.class);
+ private DataBroker dataBroker;
+
+ public SimpletxBaDelete(DataBroker dataBroker, int outerListElem, int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.dataBroker = dataBroker;
+ LOG.info("Created SimpletxBaDelete");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("DatastoreDelete: creating data in the data store");
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ SimpletxBaWrite dd = new SimpletxBaWrite(dataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ long putCnt = 0;
+
+ for (long l = 0; l < outerListElem; l++) {
+ InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+ .child(OuterList.class, new OuterListKey((int)l));
+ tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
+ putCnt++;
+ if (putCnt == writesPerTx) {
+ try {
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed: {}", e.toString());
+ txError++;
+ }
+ tx = dataBroker.newWriteOnlyTransaction();
+ putCnt = 0;
+ }
+ }
+ if (putCnt != 0) {
+ try {
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed: {}", e.toString());
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.simpletx;
+
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SimpletxBaRead extends DatastoreAbstractWriter {
+ private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxBaRead.class);
+ private DataBroker dataBroker;
+
+ public SimpletxBaRead(DataBroker dataBroker, int outerListElem, int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.dataBroker = dataBroker;
+ LOG.info("Created SimpletxBaRead");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("DatastoreRead: creating data in the data store");
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ SimpletxBaWrite dd = new SimpletxBaWrite(dataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+ ReadTransaction tx = dataBroker.newReadOnlyTransaction();
+
+ for (long l = 0; l < outerListElem; l++) {
+
+ OuterList outerList;
+ InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+ .child(OuterList.class, new OuterListKey((int)l));
+ Optional<OuterList> optionalDataObject;
+ CheckedFuture<Optional<OuterList>, ReadFailedException> submitFuture = tx.read(LogicalDatastoreType.CONFIGURATION, iid);
+ try {
+ optionalDataObject = submitFuture.checkedGet();
+ if (optionalDataObject != null && optionalDataObject.isPresent()) {
+ outerList = optionalDataObject.get();
+
+ String[] objectsArray = new String[outerList.getInnerList().size()];
+
+ //LOG.info("innerList element: " + objectsArray );
+ for (InnerList innerList : outerList.getInnerList()) {
+ if (objectsArray[innerList.getName()] != null) {
+ LOG.error("innerList: DUPLICATE name: {}, value: {}", innerList.getName(), innerList.getValue());
+ }
+ objectsArray[innerList.getName()] = innerList.getValue();
+ // LOG.info("innerList: name: {}, value: {}", innerList.getName(), innerList.getValue());
+ }
+ boolean foundAll = true;
+ for (int i = 0; i < outerList.getInnerList().size(); i++) {
+ String itemStr = objectsArray[i];
+ if (!itemStr.contentEquals("Item-" + String.valueOf(l) + "-" + String.valueOf(i))) {
+ foundAll = false;
+ LOG.error("innerList: name: {}, value: {}", i, itemStr);
+ break;
+ }
+ }
+ txOk++;
+ } else {
+ txError++;
+ }
+ } catch (ReadFailedException e) {
+ LOG.warn("failed to ....", e);
+ txError++;
+ }
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.simpletx;
+
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.dsbenchmark.BaListBuilder;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SimpletxBaWrite extends DatastoreAbstractWriter {
+ private static final Logger LOG = LoggerFactory.getLogger(SimpletxBaWrite.class);
+ private final DataBroker dataBroker;
+ private List<OuterList> list;
+
+ public SimpletxBaWrite(DataBroker dataBroker, StartTestInput.Operation oper,
+ int outerListElem, int innerListElem, long writesPerTx) {
+ super(oper, outerListElem, innerListElem, writesPerTx);
+ this.dataBroker = dataBroker;
+ LOG.info("Created SimpletxBaWrite");
+ }
+
+ @Override
+ public void createList() {
+ list = BaListBuilder.buildOuterList(this.outerListElem, this.innerListElem);
+ }
+
+ @Override
+ public void executeList() {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ long writeCnt = 0;
+
+ for (OuterList element : this.list) {
+ InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+ .child(OuterList.class, element.getKey());
+ if (oper == StartTestInput.Operation.PUT) {
+ tx.put(LogicalDatastoreType.CONFIGURATION, iid, element);
+ } else {
+ tx.merge(LogicalDatastoreType.CONFIGURATION, iid, element);
+ }
+
+ writeCnt++;
+
+ if (writeCnt == writesPerTx) {
+ try {
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed: {}", e.toString());
+ txError++;
+ }
+ tx = dataBroker.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+
+ if (writeCnt != 0) {
+ try {
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed: {}", e.toString());
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.simpletx;
+
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SimpletxDomDelete extends DatastoreAbstractWriter {
+ private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxDomDelete.class);
+ private final DOMDataBroker domDataBroker;
+
+ public SimpletxDomDelete(DOMDataBroker domDataBroker, int outerListElem,
+ int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.domDataBroker = domDataBroker;
+ LOG.info("Created simpleTxDomDelete");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("SimpletxDomDelete: creating data in the data store");
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+ long writeCnt = 0;
+
+ org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
+ DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
+
+ for (int l = 0; l < outerListElem; l++) {
+ YangInstanceIdentifier yid = YangInstanceIdentifier.builder()
+ .node(TestExec.QNAME)
+ .node(OuterList.QNAME)
+ .nodeWithKey(OuterList.QNAME, OL_ID, l)
+ .build();
+
+ tx.delete(LogicalDatastoreType.CONFIGURATION, yid);
+ writeCnt++;
+ if (writeCnt == writesPerTx) {
+ try {
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed: {}", e.toString());
+ txError++;
+ }
+ tx = domDataBroker.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+ if (writeCnt != 0) {
+ try {
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed: {}", e.toString());
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.simpletx;
+
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SimpletxDomRead extends DatastoreAbstractWriter {
+ private static final Logger LOG = (Logger) LoggerFactory.getLogger(SimpletxDomRead.class);
+ private final DOMDataBroker domDataBroker;
+
+ public SimpletxDomRead(DOMDataBroker domDataBroker, int outerListElem,
+ int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.domDataBroker = domDataBroker;
+ LOG.info("Created simpleTxDomRead");
+
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("SimpletxDomRead: creating data in the data store");
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ SimpletxDomWrite dd = new SimpletxDomWrite(domDataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+ org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
+ DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction();
+
+ for (long l = 0; l < outerListElem; l++) {
+ NormalizedNode<?,?> ret = null;
+
+ YangInstanceIdentifier yid = YangInstanceIdentifier.builder()
+ .node(TestExec.QNAME)
+ .node(OuterList.QNAME)
+ .nodeWithKey(OuterList.QNAME, OL_ID, l)
+ .build();
+ Optional<NormalizedNode<?,?>> optionalDataObject;
+ CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> submitFuture = tx.read(LogicalDatastoreType.CONFIGURATION, yid);
+ try {
+ optionalDataObject = submitFuture.checkedGet();
+ if (optionalDataObject != null && optionalDataObject.isPresent()) {
+ ret = optionalDataObject.get();
+ LOG.info("/n" + String.valueOf(ret));
+ txOk++;
+ }
+ /*if (optionalDataObject != null && optionalDataObject.isPresent()) {
+ ret = optionalDataObject.get();
+
+ String[] objectsArray = new String[ret.getInnerList().size()];
+
+ //LOG.info("innerList element: " + objectsArray );
+ for (InnerList innerList : ret.getInnerList()) {
+ if (objectsArray[innerList.getName()] != null) {
+ LOG.error("innerList: DUPLICATE name: {}, value: {}", innerList.getName(), innerList.getValue());
+ }
+ objectsArray[innerList.getName()] = innerList.getValue();
+ // LOG.info("innerList: name: {}, value: {}", innerList.getName(), innerList.getValue());
+ }
+ boolean foundAll = true;
+ for (int i = 0; i < ret.getInnerList().size(); i++) {
+ String itemStr = objectsArray[i];
+ if (!itemStr.contentEquals("Item-" + String.valueOf(l) + "-" + String.valueOf(i))) {
+ foundAll = false;
+ LOG.error("innerList: name: {}, value: {}", i, itemStr);
+ break;
+ }
+ }
+ txOk++;
+ }*/ else {
+ txError++;
+ LOG.info("In the else part");
+ }
+ } catch (ReadFailedException e) {
+ LOG.warn("failed to ....", e);
+ txError++;
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.simpletx;
+
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.dsbenchmark.DomListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SimpletxDomWrite extends DatastoreAbstractWriter {
+ private static final Logger LOG = LoggerFactory.getLogger(SimpletxDomWrite.class);
+ private final DOMDataBroker domDataBroker;
+ private List<MapEntryNode> list;
+
+ public SimpletxDomWrite(DOMDataBroker domDataBroker, StartTestInput.Operation oper,
+ int outerListElem, int innerListElem, long putsPerTx ) {
+ super(oper, outerListElem, innerListElem, putsPerTx);
+ this.domDataBroker = domDataBroker;
+ LOG.info("Created SimpletxDomWrite");
+ }
+
+ @Override
+ public void createList() {
+ list = DomListBuilder.buildOuterList(this.outerListElem, this.innerListElem);
+ }
+
+ @Override
+ public void executeList() {
+ DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
+ long writeCnt = 0;
+
+ YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
+ for (MapEntryNode element : this.list) {
+ YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
+
+ if (oper == StartTestInput.Operation.PUT) {
+ tx.put(LogicalDatastoreType.CONFIGURATION, yid, element);
+ } else {
+ tx.merge(LogicalDatastoreType.CONFIGURATION, yid, element);
+ }
+
+ writeCnt++;
+
+ if (writeCnt == writesPerTx) {
+ try {
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed", e);
+ txError++;
+ }
+ tx = domDataBroker.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+
+ if (writeCnt != 0) {
+ try {
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed", e);
+ }
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.txchain;
+
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class TxchainBaDelete extends DatastoreAbstractWriter implements TransactionChainListener{
+ private static final Logger LOG = (Logger) LoggerFactory.getLogger(TxchainBaDelete.class);
+ private DataBroker bindingDataBroker;
+
+ public TxchainBaDelete(DataBroker bindingDataBroker, int outerListElem, int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.bindingDataBroker = bindingDataBroker;
+ LOG.info("Created TxchainBaDelete");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("TxchainBaDelete: creating data in the data store");
+
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ TxchainBaWrite dd = new TxchainBaWrite(bindingDataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+ int txSubmitted = 0;
+ int writeCnt = 0;
+
+ BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
+ WriteTransaction tx = chain.newWriteOnlyTransaction();
+
+ for (long l = 0; l < outerListElem; l++) {
+ InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+ .child(OuterList.class, new OuterListKey((int)l));
+ tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
+
+ writeCnt++;
+
+ if (writeCnt == writesPerTx) {
+ txSubmitted++;
+ Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ txOk++;
+ }
+ @Override
+ public void onFailure(final Throwable t) {
+ LOG.error("Transaction failed, {}", t);
+ txError++;
+ }
+ });
+ tx = chain.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+
+ // Submit the outstanding transaction even if it's empty and wait for it to finish
+ // We need to empty the chain before closing it
+ try {
+ if (writeCnt > 0) {
+ txSubmitted++;
+ }
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed", e);
+ }
+ try {
+ chain.close();
+ }
+ catch (IllegalStateException e){
+ LOG.error("Transaction close failed,", e);
+ }
+ LOG.info("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
+ }
+
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain,
+ AsyncTransaction<?, ?> transaction, Throwable cause) {
+ LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}",
+ chain, transaction.getIdentifier(), cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ LOG.info("TxchainBaDelete closed successfully, chain {}", chain);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.txchain;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.*;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TxchainBaRead extends DatastoreAbstractWriter implements TransactionChainListener{
+ private static final Logger LOG = (Logger) LoggerFactory.getLogger(TxchainBaRead.class);
+ private DataBroker bindingDataBroker;
+
+ public TxchainBaRead(DataBroker bindingDataBroker, int outerListElem, int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.bindingDataBroker = bindingDataBroker;
+ LOG.info("Created TxchainBaRead");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("TxchainBaRead: reading data in the data store");
+
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ TxchainBaWrite dd = new TxchainBaWrite(bindingDataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+
+ BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
+ ReadTransaction tx = bindingDataBroker.newReadOnlyTransaction();
+
+ for (long l = 0; l < outerListElem; l++) {
+
+ OuterList outerList;
+ InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+ .child(OuterList.class, new OuterListKey((int) l));
+ Optional<OuterList> optionalDataObject;
+ CheckedFuture<Optional<OuterList>, ReadFailedException> submitFuture = tx.read(LogicalDatastoreType.CONFIGURATION, iid);
+
+ try {
+ optionalDataObject = submitFuture.checkedGet();
+ /*if (optionalDataObject != null && optionalDataObject.isPresent()) {
+ ret = optionalDataObject.get();
+ txOk++;
+ }*/
+ if (optionalDataObject != null && optionalDataObject.isPresent()) {
+ outerList = optionalDataObject.get();
+
+ String[] objectsArray = new String[outerList.getInnerList().size()];
+
+ //LOG.info("innerList element: " + objectsArray );
+ for (InnerList innerList : outerList.getInnerList()) {
+ if (objectsArray[innerList.getName()] != null) {
+ LOG.error("innerList: DUPLICATE name: {}, value: {}", innerList.getName(), innerList.getValue());
+ }
+ objectsArray[innerList.getName()] = innerList.getValue();
+ // LOG.info("innerList: name: {}, value: {}", innerList.getName(), innerList.getValue());
+ }
+ boolean foundAll = true;
+ for (int i = 0; i < outerList.getInnerList().size(); i++) {
+ String itemStr = objectsArray[i];
+ if (!itemStr.contentEquals("Item-" + String.valueOf(l) + "-" + String.valueOf(i))) {
+ foundAll = false;
+ LOG.error("innerList: name: {}, value: {}", i, itemStr);
+ break;
+ }
+ }
+ txOk++;
+ }
+ else {
+ txError++;
+ }
+ } catch (ReadFailedException e) {
+ LOG.warn("failed to ....", e);
+ txError++;
+ }
+ }
+ }
+
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain,
+ AsyncTransaction<?, ?> transaction, Throwable cause) {
+ LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}",
+ chain, transaction.getIdentifier(), cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ LOG.info("TxchainBaDelete closed successfully, chain {}", chain);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.txchain;
+
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.dsbenchmark.BaListBuilder;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.Operation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class TxchainBaWrite extends DatastoreAbstractWriter implements TransactionChainListener {
+ private static final Logger LOG = LoggerFactory.getLogger(TxchainBaWrite.class);
+ private final DataBroker bindingDataBroker;
+ private List<OuterList> list;
+
+ public TxchainBaWrite(DataBroker bindingDataBroker, Operation oper,
+ int outerListElem, int innerListElem, long writesPerTx) {
+ super(oper, outerListElem, innerListElem, writesPerTx);
+ this.bindingDataBroker = bindingDataBroker;
+ LOG.info("Created TxchainBaWrite");
+ }
+
+ @Override
+ public void createList() {
+ list = BaListBuilder.buildOuterList(this.outerListElem, this.innerListElem);
+ }
+
+ @Override
+ public void executeList() {
+ int txSubmitted = 0;
+ int writeCnt = 0;
+
+ BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
+ WriteTransaction tx = chain.newWriteOnlyTransaction();
+
+ for (OuterList element : this.list) {
+ InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
+ .child(OuterList.class, element.getKey());
+ if (oper == StartTestInput.Operation.PUT) {
+ tx.put(LogicalDatastoreType.CONFIGURATION, iid, element);
+ } else {
+ tx.merge(LogicalDatastoreType.CONFIGURATION, iid, element);
+ }
+
+ writeCnt++;
+
+ if (writeCnt == writesPerTx) {
+ txSubmitted++;
+ Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ txOk++;
+ }
+ @Override
+ public void onFailure(final Throwable t) {
+ LOG.error("Transaction failed, {}", t);
+ txError++;
+ }
+ });
+ tx = chain.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+
+ // *** Clean up and close the transaction chain ***
+ // Submit the outstanding transaction even if it's empty and wait for it to finish
+ // We need to empty the transaction chain before closing it
+ try {
+ txSubmitted++;
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed", e);
+ txError++;
+ }
+ try {
+ chain.close();
+ }
+ catch (IllegalStateException e){
+ LOG.error("Transaction close failed,", e);
+ }
+ LOG.info("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
+ }
+
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain,
+ AsyncTransaction<?, ?> transaction, Throwable cause) {
+ LOG.error("Broken chain {} in DatastoreBaAbstractWrite, transaction {}, cause {}",
+ chain, transaction.getIdentifier(), cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ LOG.info("DatastoreBaAbstractWrite closed successfully, chain {}", chain);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.txchain;
+
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class TxchainDomDelete extends DatastoreAbstractWriter implements TransactionChainListener{
+ private static final Logger LOG = LoggerFactory.getLogger(TxchainBaWrite.class);
+ private final DOMDataBroker domDataBroker;
+
+ public TxchainDomDelete(DOMDataBroker domDataBroker, int outerListElem, int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.domDataBroker = domDataBroker;
+ LOG.info("Created TxchainDomDelete");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("TxchainDomDelete: creating data in the data store");
+
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ TxchainDomWrite dd = new TxchainDomWrite(domDataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+ int txSubmitted = 0;
+ int writeCnt = 0;
+
+ org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
+ DOMTransactionChain chain = domDataBroker.createTransactionChain(this);
+ DOMDataWriteTransaction tx = chain.newWriteOnlyTransaction();
+
+ YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
+ for (int l = 0; l < outerListElem; l++) {
+ YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, OL_ID, l));
+ tx.delete(LogicalDatastoreType.CONFIGURATION, yid);
+
+ writeCnt++;
+
+ if (writeCnt == writesPerTx) {
+ txSubmitted++;
+ Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ txOk++;
+ }
+ @Override
+ public void onFailure(final Throwable t) {
+ LOG.error("Transaction failed, {}", t);
+ txError++;
+ }
+ });
+ tx = chain.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+
+ // *** Clean up and close the transaction chain ***
+ // Submit the outstanding transaction even if it's empty and wait for it to finish
+ // We need to empty the transaction chain before closing it
+ try {
+ txSubmitted++;
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed", e);
+ txError++;
+ }
+ try {
+ chain.close();
+ }
+ catch (IllegalStateException e){
+ LOG.error("Transaction close failed,", e);
+ }
+ LOG.info("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
+ }
+
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain,
+ AsyncTransaction<?, ?> transaction, Throwable cause) {
+ LOG.error("Broken chain {} in TxchainDomDelete, transaction {}, cause {}",
+ chain, transaction.getIdentifier(), cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ LOG.info("TxchainDomDelete closed successfully, chain {}", chain);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.txchain;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.md.sal.common.api.data.*;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TxchainDomRead extends DatastoreAbstractWriter implements TransactionChainListener{
+ private static final Logger LOG = LoggerFactory.getLogger(TxchainDomRead.class);
+ private final DOMDataBroker domDataBroker;
+
+ public TxchainDomRead(DOMDataBroker domDataBroker, int outerListElem, int innerListElem, long writesPerTx) {
+ super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx);
+ this.domDataBroker = domDataBroker;
+ LOG.info("Created TxchainDomDelete");
+ }
+
+ @Override
+ public void createList() {
+ LOG.info("TxchainDomDelete: creating data in the data store");
+
+ // Dump the whole list into the data store in a single transaction
+ // with <outerListElem> PUTs on the transaction
+ TxchainDomWrite dd = new TxchainDomWrite(domDataBroker,
+ StartTestInput.Operation.PUT,
+ outerListElem,
+ innerListElem,
+ outerListElem);
+ dd.createList();
+ dd.executeList();
+ }
+
+ @Override
+ public void executeList() {
+
+ org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
+ DOMTransactionChain chain = domDataBroker.createTransactionChain(this);
+ DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction();
+
+ YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
+ for (int l = 0; l < outerListElem; l++) {
+ NormalizedNode<?,?> ret;
+ YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, OL_ID, l));
+ Optional<NormalizedNode<?,?>> optionalDataObject;
+ CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> submitFuture = tx.read(LogicalDatastoreType.CONFIGURATION, yid);
+ try {
+ optionalDataObject = submitFuture.checkedGet();
+ if (optionalDataObject != null && optionalDataObject.isPresent()) {
+ ret = optionalDataObject.get();
+ txOk++;
+ }
+ } catch (ReadFailedException e) {
+ LOG.warn("failed to ....", e);
+ txError++;
+ }
+ }
+
+
+ }
+
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain,
+ AsyncTransaction<?, ?> transaction, Throwable cause) {
+ LOG.error("Broken chain {} in TxchainDomDelete, transaction {}, cause {}",
+ chain, transaction.getIdentifier(), cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ LOG.info("TxchainDomDelete closed successfully, chain {}", chain);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.dsbenchmark.txchain;
+
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.dsbenchmark.DomListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class TxchainDomWrite extends DatastoreAbstractWriter implements TransactionChainListener {
+ private static final Logger LOG = LoggerFactory.getLogger(TxchainDomWrite.class);
+ private final DOMDataBroker domDataBroker;
+ private List<MapEntryNode> list;
+
+ public TxchainDomWrite(DOMDataBroker domDataBroker, StartTestInput.Operation oper, int outerListElem,
+ int innerListElem, long writesPerTx) {
+ super(oper, outerListElem, innerListElem, writesPerTx);
+ this.domDataBroker = domDataBroker;
+ LOG.info("Created TxchainDomWrite");
+ }
+
+ @Override
+ public void createList() {
+ list = DomListBuilder.buildOuterList(this.outerListElem, this.innerListElem);
+ }
+
+ @Override
+ public void executeList() {
+ int txSubmitted = 0;
+ int writeCnt = 0;
+
+ DOMTransactionChain chain = domDataBroker.createTransactionChain(this);
+ DOMDataWriteTransaction tx = chain.newWriteOnlyTransaction();
+
+ YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
+ for (MapEntryNode element : this.list) {
+ YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
+
+ if (oper == StartTestInput.Operation.PUT) {
+ tx.put(LogicalDatastoreType.CONFIGURATION, yid, element);
+ } else {
+ tx.merge(LogicalDatastoreType.CONFIGURATION, yid, element);
+ }
+
+ writeCnt++;
+
+ if (writeCnt == writesPerTx) {
+ txSubmitted++;
+ Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ txOk++;
+ }
+ @Override
+ public void onFailure(final Throwable t) {
+ LOG.error("Transaction failed, {}", t);
+ txError++;
+ }
+ });
+ tx = chain.newWriteOnlyTransaction();
+ writeCnt = 0;
+ }
+ }
+
+ // *** Clean up and close the transaction chain ***
+ // Submit the outstanding transaction even if it's empty and wait for it to finish
+ // We need to empty the transaction chain before closing it
+ try {
+ txSubmitted++;
+ tx.submit().checkedGet();
+ txOk++;
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("Transaction failed", e);
+ txError++;
+ }
+ try {
+ chain.close();
+ }
+ catch (IllegalStateException e){
+ LOG.error("Transaction close failed,", e);
+ }
+ LOG.info("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
+ }
+
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain,
+ AsyncTransaction<?, ?> transaction, Throwable cause) {
+ LOG.error("Broken chain {} in TxchainDomWrite, transaction {}, cause {}",
+ chain, transaction.getIdentifier(), cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ LOG.info("Chain {} closed successfully", chain);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.impl.rev141210;
+
+import org.opendaylight.dsbenchmark.DsbenchmarkProvider;
+
+public class DsbenchmarkImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.impl.rev141210.AbstractDsbenchmarkImplModule {
+ public DsbenchmarkImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public DsbenchmarkImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.impl.rev141210.DsbenchmarkImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ DsbenchmarkProvider provider = new DsbenchmarkProvider(getDomDataBrokerDependency(),
+ getBindingDataBrokerDependency());
+ getBrokerDependency().registerProvider(provider);
+ return provider;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+/*
+* Generated file
+*
+* Generated from: yang module name: dsbenchmark yang module local name: dsbenchmark
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Jan 02 13:49:24 CST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.impl.rev141210;
+public class DsbenchmarkImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.impl.rev141210.AbstractDsbenchmarkImplModuleFactory {
+
+}
--- /dev/null
+module dsbenchmark-impl {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:dsbenchmark:impl";
+ prefix "dsbenchmark-impl";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+ import opendaylight-md-sal-dom { prefix md-sal-dom; revision-date 2013-10-28;}
+
+ description
+ "Service definition for dsbenchmark project";
+
+ revision "2014-12-10" {
+ description
+ "Initial revision";
+ }
+
+ identity dsbenchmark-impl {
+ base config:module-type;
+ config:java-name-prefix DsbenchmarkImpl;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case dsbenchmark-impl {
+ when "/config:modules/config:module/config:type = 'dsbenchmark-impl'";
+ container broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-binding:binding-broker-osgi-registry;
+ }
+ }
+ }
+ container dom-data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-dom:dom-async-data-broker;
+ }
+ }
+ }
+ container binding-data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-binding:binding-async-data-broker;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>benchmark-aggregator</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.1.1</maven>
+ </prerequisites>
+ <modules>
+ <module>api</module>
+ <module>dsbenchmark</module>
+ <module>artifacts</module>
+ </modules>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Cisco Systems and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>features-parent</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>benchmark-features</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.1.1</maven>
+ </prerequisites>
+
+ <properties>
+ <controller.mdsal.version>1.3.0-SNAPSHOT</controller.mdsal.version>
+ <mdsal.version>2.0.0-SNAPSHOT</mdsal.version>
+ <mdsal.model.version>0.8.0-SNAPSHOT</mdsal.model.version>
+ <yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
+ <config.benchmark.configfile>04-xsql.xml</config.benchmark.configfile>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <classifier>features</classifier>
+ <version>${yangtools.version}</version>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <version>${mdsal.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>features-mdsal-model</artifactId>
+ <version>${mdsal.model.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <version>${controller.mdsal.version}</version>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>dsbenchmark</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>dsbenchmark</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>config</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>benchmark-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Cisco Systems
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<features name="odl-dsbenchmark-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <repository>mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
+
+ <feature name='odl-benchmark-api' version='${project.version}' description='OpenDaylight :: dsbenchmark :: api '>
+ <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
+ <bundle>mvn:org.opendaylight.controller/benchmark-api/{{VERSION}}</bundle>
+ </feature>
+ <feature name='odl-dsbenchmark' version='${project.version}' description='OpenDaylight :: dsbenchmark :: '>
+ <feature version='${controller.mdsal.version}'>odl-mdsal-broker</feature>
+ <feature version='${project.version}'>odl-benchmark-api</feature>
+ <bundle>mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}}</bundle>
+ <configfile finalname="dsbenchmark-impl-default-config.xml">mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}}/xml/config</configfile>
+ </feature>
+</features>
<module>protocol-framework</module>
<module>akka</module>
<module>extras</module>
+ <module>benchmark</module>
</modules>
</project>
<module>opendaylight/commons/filter-valve</module>
<module>opendaylight/commons/liblldp</module>
<module>opendaylight/commons/enunciate-parent</module>
+ <module>benchmark</module>
<!-- Karaf Distribution -->
<module>karaf</module>