From 271e4eb62726c79f2e029fa65704dc6d0fc845e4 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 8 Jul 2019 16:02:51 +0200 Subject: [PATCH] Migrate to MD-SAL APIs This removes controller dependencies. Change-Id: Ic3fa0748d4e92f86899af2b8dcf73b7f1ae2560a Signed-off-by: Robert Varga --- .../md-sal/benchmark-data-store/pom.xml | 12 ++++--- ...MemoryBrokerWriteTransactionBenchmark.java | 35 +++++++++---------- ...oryDatastoreWriteTransactionBenchmark.java | 6 ++-- .../dom/store/benchmark/BenchmarkModel.java | 18 +--------- ...MemoryBrokerWriteTransactionBenchmark.java | 8 ++--- ...toreWithSameThreadedExecutorBenchmark.java | 5 +-- ...oryDataStoreWriteTransactionBenchmark.java | 2 +- 7 files changed, 37 insertions(+), 49 deletions(-) diff --git a/opendaylight/md-sal/benchmark-data-store/pom.xml b/opendaylight/md-sal/benchmark-data-store/pom.xml index 520bc56ede..b5204fec77 100644 --- a/opendaylight/md-sal/benchmark-data-store/pom.xml +++ b/opendaylight/md-sal/benchmark-data-store/pom.xml @@ -21,6 +21,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html 1.10.0-SNAPSHOT jar + + true + + org.opendaylight.yangtools @@ -37,12 +41,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html 1.17.5 - org.opendaylight.controller - sal-inmemory-datastore + org.opendaylight.mdsal + mdsal-dom-inmemory-datastore - org.opendaylight.controller - sal-broker-impl + org.opendaylight.mdsal + mdsal-dom-broker org.opendaylight.yangtools diff --git a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryBrokerWriteTransactionBenchmark.java b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryBrokerWriteTransactionBenchmark.java index 04298a66fe..c9836ded43 100644 --- a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryBrokerWriteTransactionBenchmark.java +++ b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryBrokerWriteTransactionBenchmark.java @@ -8,10 +8,9 @@ package org.opendaylight.controller.md.sal.dom.store.benchmark; import java.util.concurrent.TimeUnit; - -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; +import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; @@ -29,10 +28,10 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark protected void initTestNode() throws Exception { final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH).build(); - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); writeTx.put(LogicalDatastoreType.OPERATIONAL, testPath, provideOuterListNode()); - writeTx.submit().get(); + writeTx.commit().get(); } @Benchmark @@ -40,13 +39,13 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) { writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]); } - writeTx.submit().get(); + writeTx.commit().get(); } @Benchmark @@ -54,11 +53,11 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception { for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]); - writeTx.submit().get(); + writeTx.commit().get(); } } @@ -66,13 +65,13 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) { writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]); } - writeTx.submit().get(); + writeTx.commit().get(); } @Benchmark @@ -80,10 +79,10 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception { for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]); - writeTx.submit().get(); + writeTx.commit().get(); } } @@ -91,12 +90,12 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) { writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]); } - writeTx.submit().get(); + writeTx.commit().get(); } @Benchmark @@ -104,10 +103,10 @@ public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS) public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception { for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]); - writeTx.submit().get(); + writeTx.commit().get(); } } } diff --git a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryDatastoreWriteTransactionBenchmark.java b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryDatastoreWriteTransactionBenchmark.java index 00925a562d..473da352fa 100644 --- a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryDatastoreWriteTransactionBenchmark.java +++ b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/AbstractInMemoryDatastoreWriteTransactionBenchmark.java @@ -8,9 +8,9 @@ package org.opendaylight.controller.md.sal.dom.store.benchmark; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/BenchmarkModel.java b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/BenchmarkModel.java index d2d3b51048..20e107402a 100644 --- a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/BenchmarkModel.java +++ b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/BenchmarkModel.java @@ -7,13 +7,9 @@ */ package org.opendaylight.controller.md.sal.dom.store.benchmark; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; /** @@ -40,19 +36,7 @@ public final class BenchmarkModel { private BenchmarkModel() { } - private static InputStream getInputStream() { - return BenchmarkModel.class.getResourceAsStream(DATASTORE_TEST_YANG); - } - public static SchemaContext createTestContext() { - final SchemaContext schemaContext; - final List streams = Collections.singletonList(getInputStream()); - - try { - schemaContext = YangParserTestUtils.parseYangStreams(streams); - } catch (ReactorException e) { - throw new RuntimeException("Unable to build schema context from " + streams, e); - } - return schemaContext; + return YangParserTestUtils.parseYangResources(BenchmarkModel.class, DATASTORE_TEST_YANG); } } diff --git a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryBrokerWriteTransactionBenchmark.java b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryBrokerWriteTransactionBenchmark.java index 7c0b4b7d07..a0a096ed33 100644 --- a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryBrokerWriteTransactionBenchmark.java +++ b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryBrokerWriteTransactionBenchmark.java @@ -14,10 +14,10 @@ import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker; +import org.opendaylight.mdsal.dom.spi.store.DOMStore; +import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; diff --git a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWithSameThreadedExecutorBenchmark.java b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWithSameThreadedExecutorBenchmark.java index 037058848e..2e236c56e0 100644 --- a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWithSameThreadedExecutorBenchmark.java +++ b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWithSameThreadedExecutorBenchmark.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.store.benchmark; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; +import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -44,7 +44,8 @@ public class InMemoryDataStoreWithSameThreadedExecutorBenchmark public void setUp() throws Exception { final String name = "DS_BENCHMARK"; final ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool( - MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, name + "-DCL"); + MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, name + "-DCL", + InMemoryDataStoreWithSameThreadedExecutorBenchmark.class); domStore = new InMemoryDOMDataStore("SINGLE_THREADED_DS_BENCHMARK", dataChangeListenerExecutor); schemaContext = BenchmarkModel.createTestContext(); diff --git a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWriteTransactionBenchmark.java b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWriteTransactionBenchmark.java index fee7eca788..c614085fee 100644 --- a/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWriteTransactionBenchmark.java +++ b/opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/InMemoryDataStoreWriteTransactionBenchmark.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.store.benchmark; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; +import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; -- 2.36.6