X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fshardstrategy%2FShardStrategyFactory.java;h=7d077b8559e0bacf01fac172b936cce3c88399ca;hb=ffc46de334c8a903844b9f4aff73dc68b2401659;hp=f4ab8fab6f768e84bd48c15ebc83e862315e09eb;hpb=ed693440aa741fee9b94447f8404d89b4020f616;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java index f4ab8fab6f..7d077b8559 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java @@ -10,26 +10,25 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; import com.google.common.base.Optional; import com.google.common.base.Preconditions; -import org.opendaylight.controller.cluster.datastore.Configuration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.opendaylight.controller.cluster.datastore.config.Configuration; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ShardStrategyFactory { private static Map moduleNameToStrategyMap = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); private static final String UNKNOWN_MODULE_NAME = "unknown"; private static Configuration configuration; - public static void setConfiguration(Configuration configuration){ + public static void setConfiguration(final Configuration configuration){ ShardStrategyFactory.configuration = configuration; moduleNameToStrategyMap = configuration.getModuleNameToShardStrategyMap(); } - public static ShardStrategy getStrategy(YangInstanceIdentifier path) { + public static ShardStrategy getStrategy(final YangInstanceIdentifier path) { Preconditions.checkState(configuration != null, "configuration should not be missing"); Preconditions.checkNotNull(path, "path should not be null"); @@ -37,14 +36,14 @@ public class ShardStrategyFactory { String moduleName = getModuleName(path); ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName); if (shardStrategy == null) { - return new DefaultShardStrategy(); + return DefaultShardStrategy.getInstance(); } return shardStrategy; } - private static String getModuleName(YangInstanceIdentifier path) { + private static String getModuleName(final YangInstanceIdentifier path) { String namespace = path.getPathArguments().iterator().next().getNodeType().getNamespace().toASCIIString(); Optional optional =