X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fshardstrategy%2FShardStrategyFactory.java;h=0a93c0d6b3458710950e318495cad9861057b7c2;hb=HEAD;hp=e63ab9744514cf2fd94e4d822df3fc020ce52058;hpb=8f333ba6544e8f85dcf10dd6a4cf235ff6e0ddef;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 e63ab97445..0a93c0d6b3 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 @@ -5,41 +5,29 @@ * 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.shardstrategy; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; + import org.opendaylight.controller.cluster.datastore.config.Configuration; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ShardStrategyFactory { private static final String UNKNOWN_MODULE_NAME = "unknown"; private final Configuration configuration; - private final LogicalDatastoreType logicalStoreType; - public ShardStrategyFactory(final Configuration configuration, final LogicalDatastoreType logicalStoreType) { - Preconditions.checkState(configuration != null, "configuration should not be missing"); + public ShardStrategyFactory(final Configuration configuration) { + checkState(configuration != null, "configuration should not be missing"); this.configuration = configuration; - this.logicalStoreType = Preconditions.checkNotNull(logicalStoreType); } public ShardStrategy getStrategy(final YangInstanceIdentifier path) { - Preconditions.checkNotNull(path, "path should not be null"); - - // try with the legacy module based shard mapping - final String moduleName = getModuleName(path); + final String moduleName = getModuleName(requireNonNull(path, "path should not be null")); final ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName); if (shardStrategy == null) { - // retry with prefix based sharding - final ShardStrategy strategyForPrefix = - configuration.getStrategyForPrefix(new DOMDataTreeIdentifier(logicalStoreType, path)); - if (strategyForPrefix == null) { - return DefaultShardStrategy.getInstance(); - } - return strategyForPrefix; + return DefaultShardStrategy.getInstance(); } return shardStrategy; @@ -59,7 +47,7 @@ public class ShardStrategyFactory { return UNKNOWN_MODULE_NAME; } - String namespace = path.getPathArguments().get(0).getNodeType().getNamespace().toASCIIString(); + String namespace = path.getPathArguments().get(0).getNodeType().getNamespace().toString(); String moduleName = configuration.getModuleNameFromNameSpace(namespace); return moduleName != null ? moduleName : UNKNOWN_MODULE_NAME; }