Speed up DatastoreContextIntrospector a bit 96/91396/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 17 Jul 2020 16:52:12 +0000 (18:52 +0200)
committerRobert Varga <nite@hq.sk>
Sat, 18 Jul 2020 09:48:45 +0000 (09:48 +0000)
We can rely on static QNames and pre-computed YangInstanceIdentifier
to reduce the amount of transcoding we do.

Change-Id: Ibae5a6938703e12dc7584de002fb7cd0538d8289
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospector.java

index f22a98a..0d5fc9d 100644 (file)
@@ -35,15 +35,13 @@ import org.apache.commons.text.WordUtils;
 import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.distributed.datastore.provider.rev140612.DataStoreProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.distributed.datastore.provider.rev140612.DataStorePropertiesContainer;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.Uint64;
 import org.opendaylight.yangtools.yang.common.Uint8;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -215,11 +213,9 @@ public class DatastoreContextIntrospector {
 
     public DatastoreContextIntrospector(final DatastoreContext context,
             final BindingNormalizedNodeSerializer bindingSerializer) {
-        final QName qname = BindingReflections.findQName(DataStorePropertiesContainer.class);
         final DataStorePropertiesContainer defaultPropsContainer = (DataStorePropertiesContainer)
-                bindingSerializer.fromNormalizedNode(bindingSerializer.toYangInstanceIdentifier(
-                        InstanceIdentifier.builder(DataStorePropertiesContainer.class).build()),
-                ImmutableNodes.containerNode(qname)).getValue();
+                bindingSerializer.fromNormalizedNode(YangInstanceIdentifier.of(DataStorePropertiesContainer.QNAME),
+                ImmutableNodes.containerNode(DataStorePropertiesContainer.QNAME)).getValue();
 
         final Builder builder = DatastoreContext.newBuilderFrom(context);
         for (Entry<String, Entry<Class<?>, Method>> entry: DATA_STORE_PROP_INFO.entrySet()) {

©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.