X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FQNameFactory.java;h=1b9a21f85e1b1ba24014a51ed09c4e21492f36d2;hp=5c7f6d1a5650333ca1cee7124ff0edd47a8c0378;hb=dc54b87a6b2fb11d233b8294b684268f4d5161de;hpb=877dc93c690dba7b2a834e0cf585d45250eb9aa2 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java index 5c7f6d1a56..1b9a21f85e 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java @@ -5,7 +5,6 @@ * 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.controller.cluster.datastore.node.utils; import com.google.common.cache.CacheBuilder; @@ -14,21 +13,22 @@ import com.google.common.cache.LoadingCache; import org.opendaylight.yangtools.yang.common.QName; public final class QNameFactory { - - private static final int MAX_QNAME_CACHE_SIZE = 10000; - - private QNameFactory() { - } + private static final int MAX_QNAME_CACHE_SIZE = Integer.getInteger( + "org.opendaylight.controller.cluster.datastore.node.utils.qname-cache.max-size", 10000); private static final LoadingCache CACHE = CacheBuilder.newBuilder().maximumSize(MAX_QNAME_CACHE_SIZE) - .softValues().build(new CacheLoader() { + .weakValues().build(new CacheLoader() { @Override - public QName load(String key) { - return QName.create(key); + public QName load(final String key) { + return QName.create(key).intern(); } }); - public static QName create(String name) { + private QNameFactory() { + + } + + public static QName create(final String name) { return CACHE.getUnchecked(name); } }