X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FDOMBrokerPerformanceTest.java;h=72a3c2e962d3f9e3837b6c577f1c85f833271344;hp=467acf05d8c9bdf8c0c3b1f96dcc6358d71148e3;hb=a6af137c30470b86d4bc624d4c48cb686495a182;hpb=f6d4d8759fcce4d35f38f5a5a056acf1d3e0b4b2 diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java index 467acf05d8..72a3c2e962 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; + import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Futures; @@ -41,13 +42,13 @@ public class DOMBrokerPerformanceTest { private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerPerformanceTest.class); - private static NormalizedNode outerList(final int i) { - return ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i); + private static NormalizedNode outerList(final int index) { + return ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, index); } - private static YangInstanceIdentifier outerListPath(final int i) { + private static YangInstanceIdentifier outerListPath(final int index) { return YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)// - .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i) // + .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, index) // .build(); } @@ -75,7 +76,7 @@ public class DOMBrokerPerformanceTest { operStore.onGlobalContextUpdated(schemaContext); configStore.onGlobalContextUpdated(schemaContext); - ImmutableMap stores = ImmutableMap. builder() // + ImmutableMap stores = ImmutableMap.builder() // .put(CONFIGURATION, configStore) // .put(OPERATIONAL, operStore) // .build(); @@ -106,69 +107,63 @@ public class DOMBrokerPerformanceTest { } private void measureSeparateWritesOneLevel(final int txNum, final int innerNum) throws Exception { - final List transactions = measure("Txs:"+ txNum + " Allocate", - () -> { - List builder = new ArrayList<>(txNum); - for (int i = 0; i < txNum; i++) { - DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); - builder.add(writeTx); - } - return builder; - }); + final List transactions = measure("Txs:" + txNum + " Allocate", () -> { + List builder = new ArrayList<>(txNum); + for (int i = 0; i < txNum; i++) { + DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction(); + builder.add(writeTx); + } + return builder; + }); assertEquals(txNum, transactions.size()); - measure("Txs:"+ txNum + " Writes:1", (Callable) () -> { - int i = 0; - for (DOMDataReadWriteTransaction writeTx :transactions) { + measure("Txs:" + txNum + " Writes:1", (Callable) () -> { + int index = 0; + for (DOMDataReadWriteTransaction writeTx : transactions) { // Writes /test/outer-list/i in writeTx - writeTx.put(OPERATIONAL, outerListPath(i), outerList(i)); - i++; + writeTx.put(OPERATIONAL, outerListPath(index), outerList(index)); + index++; } return null; }); - measure("Txs:"+ txNum + " Writes:" + innerNum, (Callable) () -> { - int i = 0; - for (DOMDataReadWriteTransaction writeTx :transactions) { + measure("Txs:" + txNum + " Writes:" + innerNum, (Callable) () -> { + int index = 0; + for (DOMDataReadWriteTransaction writeTx : transactions) { // Writes /test/outer-list/i in writeTx - YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(i)) + YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(index)) .node(TestModel.INNER_LIST_QNAME).build(); writeTx.put(OPERATIONAL, path, ImmutableNodes.mapNodeBuilder(TestModel.INNER_LIST_QNAME).build()); for (int j = 0; j < innerNum; j++) { YangInstanceIdentifier innerPath = YangInstanceIdentifier.builder(path) - .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)) - .build(); - writeTx.put( - OPERATIONAL, - innerPath, - ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, - String.valueOf(j))); + .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)).build(); + writeTx.put(OPERATIONAL, innerPath, ImmutableNodes + .mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j))); } - i++; + index++; } return null; }); measure("Txs:" + txNum + " Submit, Finish", (Callable) () -> { - List> allFutures = measure(txNum + " Submits", - () -> { - List> builder = new ArrayList<>(txNum); - for (DOMDataReadWriteTransaction tx :transactions) { - builder.add(tx.submit()); - } - return builder; - }); + List> allFutures = measure(txNum + " Submits", () -> { + List> builder = new ArrayList<>(txNum); + for (DOMDataReadWriteTransaction tx : transactions) { + builder.add(tx.submit()); + } + return builder; + }); Futures.allAsList(allFutures).get(); return null; }); final DOMDataReadTransaction readTx = measure("Txs:1 (ro), Allocate", - (Callable) () -> domBroker.newReadOnlyTransaction()); + (Callable) () -> domBroker + .newReadOnlyTransaction()); - measure("Txs:1 (ro) Reads:" + txNum + " (1-level)" , (Callable) () -> { + measure("Txs:1 (ro) Reads:" + txNum + " (1-level)", (Callable) () -> { for (int i = 0; i < txNum; i++) { - ListenableFuture>> potential = readTx.read(OPERATIONAL, - outerListPath(i)); + ListenableFuture>> potential = readTx.read(OPERATIONAL, outerListPath(i)); assertTrue("outerList/" + i, potential.get().isPresent()); } return null; @@ -177,12 +172,10 @@ public class DOMBrokerPerformanceTest { measure("Txs:1 (ro) Reads:" + txNum * innerNum + " (2-level)", (Callable) () -> { for (int i = 0; i < txNum; i++) { for (int j = 0; j < innerNum; j++) { - YangInstanceIdentifier path = YangInstanceIdentifier - .builder(outerListPath(i)) + YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(i)) // .node(TestModel.INNER_LIST_QNAME) - .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)) - .build(); + .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)).build(); ListenableFuture>> potential = readTx.read(OPERATIONAL, path); assertTrue("outer-list/" + i + "/inner-list/" + j, potential.get().isPresent()); } @@ -193,33 +186,34 @@ public class DOMBrokerPerformanceTest { private void measureOneTransactionTopContainer() throws Exception { - final DOMDataReadWriteTransaction writeTx = measure("Txs:1 Allocate", () -> domBroker.newReadWriteTransaction()); + final DOMDataReadWriteTransaction writeTx = + measure("Txs:1 Allocate", () -> domBroker.newReadWriteTransaction()); measure("Txs:1 Write", (Callable) () -> { writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); writeTx.put(OPERATIONAL, TestModel.OUTER_LIST_PATH, - ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()); + ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()); return null; }); measure("Txs:1 Reads:1", (Callable) () -> { // Reads /test in writeTx - ListenableFuture>> writeTxContainer = writeTx.read(OPERATIONAL, - TestModel.TEST_PATH); + ListenableFuture>> writeTxContainer = writeTx + .read(OPERATIONAL, TestModel.TEST_PATH); assertTrue(writeTxContainer.get().isPresent()); return null; }); measure("Txs:1 Reads:1", (Callable) () -> { // Reads /test in writeTx - ListenableFuture>> writeTxContainer = writeTx.read(OPERATIONAL, - TestModel.TEST_PATH); + ListenableFuture>> writeTxContainer = writeTx + .read(OPERATIONAL, TestModel.TEST_PATH); assertTrue(writeTxContainer.get().isPresent()); return null; }); measure("Txs:1 Submit, Finish", (Callable) () -> { - measure("Txs:1 Submit", (Callable>) () -> writeTx.submit()).get(); + measure("Txs:1 Submit", (Callable>) writeTx::submit).get(); return null; }); }