public ShardStrategy getStrategy(final YangInstanceIdentifier path) {
Preconditions.checkNotNull(path, "path should not be null");
- String moduleName = getModuleName(path);
- ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName);
+ // try with the legacy module based shard mapping
+ final String moduleName = getModuleName(path);
+ final ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName);
if (shardStrategy == null) {
- return DefaultShardStrategy.getInstance();
+ // retry with prefix based sharding
+ final ShardStrategy strategyForPrefix = configuration.getStrategyForPrefix(path);
+ if (strategyForPrefix == null) {
+ return DefaultShardStrategy.getInstance();
+ }
+ return strategyForPrefix;
}
return shardStrategy;