}
private IndexShardingStrategy createIndexShardingStrategy(Properties[] indexProps,
IndexManager[] indexManagers,
WorkerBuildContext buildContext) {
IndexShardingStrategy shardingStrategy;
// any indexProperty will do, the indexProps[0] surely exists.
String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
if ( shardingStrategyName == null ) {
if ( indexProps.length == 1 ) {
shardingStrategy = new NotShardedStrategy();
}
else {
shardingStrategy = new IdHashShardingStrategy();
}
}
else {
ServiceManager serviceManager = buildContext.getServiceManager();
shardingStrategy = ClassLoaderHelper.instanceFromName(
IndexShardingStrategy.class,
shardingStrategyName,
"IndexShardingStrategy",
serviceManager
);
}
shardingStrategy.initialize(
new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), indexManagers
);
return shardingStrategy;
}