X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fshardstrategy%2FShardStrategyFactory.java;h=fd786c903e87e4bc44136bf629977316250f79a3;hp=f4ab8fab6f768e84bd48c15ebc83e862315e09eb;hb=c685d3b17321084d41a94c92871da476aab39eb9;hpb=c46e223995956f1f759c551163c212947c1e2fb7 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..fd786c903e 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.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 =