- String moduleName = getModuleName(path);
- ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName);
- if(shardStrategy == null){
- return new DefaultShardStrategy();
+ 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 ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName);
+ if (shardStrategy == null) {
+ // retry with prefix based sharding
+ final ShardStrategy strategyForPrefix = configuration.getStrategyForPrefix(path);
+ if (strategyForPrefix == null) {
+ return DefaultShardStrategy.getInstance();
+ }
+ return strategyForPrefix;
+ }
+
+ return shardStrategy;