Do not use NodeIdentifierWithPredicates constructors 97/82397/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 4 Jun 2019 17:05:55 +0000 (19:05 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Tue, 4 Jun 2019 22:53:09 +0000 (22:53 +0000)
This class will transition into a value-based object for memory
efficiency reasons. Switch to using its static factory methods.

Change-Id: I7e21a6ccf1ad999d2d0427769b26dffeac166274
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 files changed:
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DomListBuilder.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomRead.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomRead.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeInputStreamReader.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SerializationUtilsTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/PrefixedShardConfigWriter.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractEntityOwnershipTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java
opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java

index 2641fea..ad47c2c 100644 (file)
@@ -35,7 +35,7 @@ public final class DomListBuilder {
         List<MapEntryNode> outerList = new ArrayList<>(outerElements);
         for (int j = 0; j < outerElements; j++) {
             outerList.add(ImmutableNodes.mapEntryBuilder()
-                                .withNodeIdentifier(new NodeIdentifierWithPredicates(OuterList.QNAME, OL_ID, j))
+                                .withNodeIdentifier(NodeIdentifierWithPredicates.of(OuterList.QNAME, OL_ID, j))
                                 .withChild(ImmutableNodes.leafNode(OL_ID, j))
                                 .withChild(buildInnerList(j, innerElements))
                                 .build());
@@ -49,7 +49,7 @@ public final class DomListBuilder {
         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))
+                                .withNodeIdentifier(NodeIdentifierWithPredicates.of(InnerList.QNAME, IL_NAME, i))
                                 .withChild(ImmutableNodes.leafNode(IL_NAME, i))
                                 .withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i)))
                                 .build());
index 2cda64b..ce70d4d 100644 (file)
@@ -60,7 +60,7 @@ public class SimpletxDomDelete extends DatastoreAbstractWriter {
         long writeCnt = 0;
 
         for (int l = 0; l < outerListElem; l++) {
-            YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
+            YangInstanceIdentifier yid = pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, olId, l));
 
             tx.delete(dsType, yid);
             writeCnt++;
index 3081289..32ae8e6 100644 (file)
@@ -61,7 +61,7 @@ public class SimpletxDomRead extends DatastoreAbstractWriter {
 
         try (DOMDataTreeReadTransaction tx = domDataBroker.newReadOnlyTransaction()) {
             for (int l = 0; l < outerListElem; l++) {
-                YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
+                YangInstanceIdentifier yid = pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, olId, l));
                 FluentFuture<Optional<NormalizedNode<?, ?>>> submitFuture = tx.read(dsType, yid);
                 try {
                     Optional<NormalizedNode<?,?>> optionalDataObject = submitFuture.get();
index 181ff23..63342b2 100644 (file)
@@ -53,7 +53,7 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter {
 
         for (MapEntryNode element : this.list) {
             YangInstanceIdentifier yid =
-                    pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
+                    pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, element.getIdentifier().getKeyValues()));
 
             if (oper == StartTestInput.Operation.PUT) {
                 tx.put(dsType, yid, element);
index 733f51d..ea0c2b9 100644 (file)
@@ -64,7 +64,7 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements DOMTran
         int writeCnt = 0;
 
         for (int l = 0; l < outerListElem; l++) {
-            YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
+            YangInstanceIdentifier yid = pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, olId, l));
             tx.delete(dsType, yid);
 
             writeCnt++;
index e54a98a..84eca17 100644 (file)
@@ -60,7 +60,7 @@ public class TxchainDomRead extends DatastoreAbstractWriter implements DOMTransa
 
         try (DOMDataTreeReadTransaction tx = domDataBroker.newReadOnlyTransaction()) {
             for (int l = 0; l < outerListElem; l++) {
-                YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
+                YangInstanceIdentifier yid = pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, olId, l));
                 Optional<NormalizedNode<?,?>> optionalDataObject;
                 FluentFuture<Optional<NormalizedNode<?, ?>>> submitFuture = tx.read(dsType, yid);
                 try {
index 2b7820e..c48709e 100644 (file)
@@ -60,7 +60,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements DOMTrans
 
         for (MapEntryNode element : this.list) {
             YangInstanceIdentifier yid =
-                    pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
+                    pid.node(NodeIdentifierWithPredicates.of(OuterList.QNAME, element.getIdentifier().getKeyValues()));
 
             if (oper == StartTestInput.Operation.PUT) {
                 tx.put(dsType, yid, element);
index d945031..b652c14 100755 (executable)
@@ -262,9 +262,9 @@ class LithiumNormalizedNodeInputStreamReader extends ForwardingDataInput impleme
         final int count = input.readInt();
         switch (count) {
             case 0:
-                return new NodeIdentifierWithPredicates(qname);
+                return NodeIdentifierWithPredicates.of(qname);
             case 1:
-                return new NodeIdentifierWithPredicates(qname, readQName(), readObject());
+                return NodeIdentifierWithPredicates.of(qname, readQName(), readObject());
             default:
                 // ImmutableList is used by ImmutableOffsetMapTemplate for lookups, hence we use that.
                 final Builder<QName> keys = ImmutableList.builderWithExpectedSize(count);
@@ -274,7 +274,7 @@ class LithiumNormalizedNodeInputStreamReader extends ForwardingDataInput impleme
                     values[i] = readObject();
                 }
 
-                return new NodeIdentifierWithPredicates(qname, ImmutableOffsetMapTemplate.ordered(keys.build())
+                return NodeIdentifierWithPredicates.of(qname, ImmutableOffsetMapTemplate.ordered(keys.build())
                     .instantiateWithValues(values));
         }
     }
index 8affb42..50bfc09 100644 (file)
@@ -211,7 +211,7 @@ public class SerializationUtilsTest {
     private static YangInstanceIdentifier.NodeIdentifierWithPredicates listId(final String listName,
                                                                               final String keyName,
                                                                               final Object keyValue) {
-        return new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(CONTAINER_Q_NAME, listName),
+        return YangInstanceIdentifier.NodeIdentifierWithPredicates.of(QName.create(CONTAINER_Q_NAME, listName),
                 QName.create(CONTAINER_Q_NAME, keyName), keyValue);
     }
 
index add933c..ebef712 100644 (file)
@@ -286,7 +286,7 @@ public final class TestModel {
         // Create YangInstanceIdentifier with all path arg types.
         YangInstanceIdentifier instanceID = YangInstanceIdentifier.create(
                 new NodeIdentifier(QName.create(TEST_QNAME, "qname")),
-                new NodeIdentifierWithPredicates(QName.create(TEST_QNAME, "list-entry"),
+                NodeIdentifierWithPredicates.of(QName.create(TEST_QNAME, "list-entry"),
                         QName.create(TEST_QNAME, "key"), 10),
                 new AugmentationIdentifier(ImmutableSet.of(
                         QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))),
@@ -359,7 +359,7 @@ public final class TestModel {
         return ImmutableMapEntryNodeBuilder
                 .create()
                 .withNodeIdentifier(
-                        new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+                        YangInstanceIdentifier.NodeIdentifierWithPredicates.of(
                                 AUGMENTED_LIST_QNAME, ID_QNAME, id))
                 .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
                 .withChild(augmentationNode).build();
index 667e45d..84705e7 100644 (file)
@@ -377,7 +377,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
 
         UnorderedMapMixinNormalization(final ListSchemaNode list) {
             super(new NodeIdentifier(list.getQName()),list);
-            this.innerNode = new ListItemNormalization(new NodeIdentifierWithPredicates(list.getQName(),
+            this.innerNode = new ListItemNormalization(NodeIdentifierWithPredicates.of(list.getQName(),
                     Collections.<QName, Object>emptyMap()), list);
         }
 
index 6451833..b69c9b3 100644 (file)
@@ -77,7 +77,7 @@ public final class EntityOwnersModel {
     }
 
     static NodeIdentifierWithPredicates candidateNodeKey(final String candidateName) {
-        return new NodeIdentifierWithPredicates(Candidate.QNAME, NODE_KEY_TEMPLATE.instantiateWithValue(candidateName));
+        return NodeIdentifierWithPredicates.of(Candidate.QNAME, NODE_KEY_TEMPLATE.instantiateWithValue(candidateName));
     }
 
     static NormalizedNode<?, ?> entityOwnersWithCandidate(final String entityType,
index 5e7f83e..90c6f3b 100644 (file)
@@ -107,7 +107,7 @@ class PrefixedShardConfigWriter {
 
     boolean checkDefaultIsPresent() {
         final NodeIdentifierWithPredicates pag =
-                new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
+                NodeIdentifierWithPredicates.of(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
                 YangInstanceIdentifier.EMPTY);
 
         final YangInstanceIdentifier defaultId = ClusterUtils.SHARD_LIST_PATH.node(pag);
@@ -138,7 +138,7 @@ class PrefixedShardConfigWriter {
 
         final MapEntryNode newEntry = ImmutableMapEntryNodeBuilder.create()
                 .withNodeIdentifier(
-                        new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
+                        NodeIdentifierWithPredicates.of(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
                                 path))
                 .withChild(ImmutableLeafNodeBuilder.create()
                         .withNodeIdentifier(new NodeIdentifier(ClusterUtils.SHARD_PREFIX_QNAME))
@@ -169,7 +169,7 @@ class PrefixedShardConfigWriter {
         ClusterUtils.SHARD_LIST_PATH.getPathArguments().forEach(cursor::enter);
 
         cursor.delete(
-                new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path));
+                NodeIdentifierWithPredicates.of(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path));
         cursor.close();
 
         return tx.ready();
index 9864323..23c77ec 100644 (file)
@@ -130,7 +130,7 @@ public class AbstractEntityOwnershipTest extends AbstractActorTest {
         assertTrue("Missing " + childMap.toString(), childNode.isPresent());
 
         MapNode entityTypeMapNode = (MapNode) childNode.get();
-        Optional<MapEntryNode> entityTypeEntry = entityTypeMapNode.getChild(new NodeIdentifierWithPredicates(
+        Optional<MapEntryNode> entityTypeEntry = entityTypeMapNode.getChild(NodeIdentifierWithPredicates.of(
                 childMap, child, key));
         if (expectPresent && !entityTypeEntry.isPresent()) {
             fail("Missing " + childMap.toString() + " entry for " + key + ". Actual: " + entityTypeMapNode.getValue());
index fb701de..a567f0a 100644 (file)
@@ -64,7 +64,7 @@ public class DistributedShardFrontendTest {
     private DOMDataTreeWriteCursor cursor;
 
     private static final YangInstanceIdentifier OUTER_LIST_YID = TestModel.OUTER_LIST_PATH.node(
-            new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
+            NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
     private static final DOMDataTreeIdentifier OUTER_LIST_ID =
             new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, OUTER_LIST_YID);
 
index d8551ae..2432fd1 100644 (file)
@@ -514,7 +514,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest {
         final Collection<MapEntryNode> ret = new ArrayList<>();
         for (int i = 0; i < amount; i++) {
             ret.add(ImmutableNodes.mapEntryBuilder()
-                    .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME,
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
                             QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
                     .withChild(ImmutableNodes
                             .leafNode(QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
@@ -534,7 +534,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest {
         final Collection<MapEntryNode> ret = new ArrayList<>();
         for (int i = 0; i < amount; i++) {
             ret.add(ImmutableNodes.mapEntryBuilder()
-                    .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.INNER_LIST_QNAME,
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME,
                             QName.create(TestModel.INNER_LIST_QNAME, "name"), Integer.toString(i)))
                     .withChild(ImmutableNodes
                             .leafNode(QName.create(TestModel.INNER_LIST_QNAME, "value"), valuePrefix + "-" + i))
@@ -545,7 +545,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest {
     }
 
     private static YangInstanceIdentifier getOuterListIdFor(final int id) {
-        return TestModel.OUTER_LIST_PATH.node(new NodeIdentifierWithPredicates(
+        return TestModel.OUTER_LIST_PATH.node(NodeIdentifierWithPredicates.of(
                 TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), id));
     }
 }
index 1f7c3fd..cfbaee6 100644 (file)
@@ -105,7 +105,7 @@ public final class TestModel {
     }
 
     public static NodeIdentifierWithPredicates outerEntryKey(final int id) {
-        return new NodeIdentifierWithPredicates(OUTER_LIST_QNAME, ID_QNAME, id);
+        return NodeIdentifierWithPredicates.of(OUTER_LIST_QNAME, ID_QNAME, id);
     }
 
     public static YangInstanceIdentifier outerEntryPath(final int id) {
@@ -113,7 +113,7 @@ public final class TestModel {
     }
 
     public static NodeIdentifierWithPredicates innerEntryKey(final String name) {
-        return new NodeIdentifierWithPredicates(INNER_LIST_QNAME, NAME_QNAME, name);
+        return NodeIdentifierWithPredicates.of(INNER_LIST_QNAME, NAME_QNAME, name);
     }
 
     public static YangInstanceIdentifier innerEntryPath(final int id, final String name) {
index edc5561..d89f0b3 100644 (file)
@@ -325,13 +325,13 @@ public class DOMDataTreeListenerTest {
                 .registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener);
 
         final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId1
-                = new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME,
+                = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
                                                                           TestModel.ID_QNAME, 1);
         final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId2
-                = new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME,
+                = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
                                                                           TestModel.ID_QNAME, 2);
         final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId3
-                = new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME,
+                = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
                                                                           TestModel.ID_QNAME, 3);
 
         final MapEntryNode outerListEntry1 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
index fe845d7..58db9d7 100644 (file)
@@ -87,13 +87,13 @@ public abstract class AbstractDataTreeChangeListenerTest {
     public static final YangInstanceIdentifier path(final String topName,
             final String nestedName) {
         return path(topName).node(NestedList.QNAME).node(
-                new NodeIdentifierWithPredicates(NestedList.QNAME, NAME_QNAME,
+                NodeIdentifierWithPredicates.of(NestedList.QNAME, NAME_QNAME,
                         nestedName));
     }
 
     public static final YangInstanceIdentifier path(final String topName) {
         return TOP_LEVEL.node(TopLevelList.QNAME).node(
-                new NodeIdentifierWithPredicates(TopLevelList.QNAME,
+                NodeIdentifierWithPredicates.of(TopLevelList.QNAME,
                         NAME_QNAME, topName));
     }
 
index db29583..c883fe0 100644 (file)
@@ -67,7 +67,7 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler
         final String id = input.getId();
         LOG.debug("Filling the item list {} with initial values.", id);
 
-        final YangInstanceIdentifier idListWithKey = ID_INT_YID.node(new NodeIdentifierWithPredicates(ID_INT, ID, id));
+        final YangInstanceIdentifier idListWithKey = ID_INT_YID.node(NodeIdentifierWithPredicates.of(ID_INT, ID, id));
 
         final DOMDataTreeProducer itemProducer = domDataTreeService.createProducer(
             Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey)));
@@ -112,7 +112,7 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler
         final DOMDataTreeCursorAwareTransaction tx = itemProducer.createTransaction(false);
         final DOMDataTreeWriteCursor cursor = tx.createCursor(idListItem);
 
-        final NodeIdentifierWithPredicates entryId = new NodeIdentifierWithPredicates(ITEM, NUMBER, i);
+        final NodeIdentifierWithPredicates entryId = NodeIdentifierWithPredicates.of(ITEM, NUMBER, i);
         if (usedValues.contains(i)) {
             LOG.debug("Deleting item: {}", i);
             deleteTx++;
index eb552b4..70b920d 100644 (file)
@@ -205,7 +205,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle
         final int i = nextInt(MAX_ITEM + 1);
 
         final YangInstanceIdentifier entryId =
-                idListItem.node(ITEM).node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(ITEM, NUMBER, i));
+                idListItem.node(ITEM).node(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(ITEM, NUMBER, i));
 
         final DOMDataWriteTransaction tx = createTransaction();
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.