AutoRebalancer autoRebalancer = new AutoRebalancer();
rebalancer = autoRebalancer;
mappingCalculator = autoRebalancer;
break;
case SEMI_AUTO:
SemiAutoRebalancer semiAutoRebalancer = new SemiAutoRebalancer();
rebalancer = semiAutoRebalancer;
mappingCalculator = semiAutoRebalancer;
break;
case CUSTOMIZED:
CustomRebalancer customRebalancer = new CustomRebalancer();
rebalancer = customRebalancer;
mappingCalculator = customRebalancer;
break;
case USER_DEFINED:
case TASK:
String rebalancerClassName = idealState.getRebalancerClassName();
logger
.info("resource " + resourceName + " use idealStateRebalancer " + rebalancerClassName);
try {
rebalancer =
Rebalancer.class.cast(HelixUtil.loadClass(getClass(), rebalancerClassName)
.newInstance());
} catch (Exception e) {
logger.warn("Exception while invoking custom rebalancer class:" + rebalancerClassName, e);
}
if (rebalancer != null) {
try {
mappingCalculator = MappingCalculator.class.cast(rebalancer);
} catch (ClassCastException e) {
logger.info("Rebalancer does not have a mapping calculator, defaulting to SEMI_AUTO");
}
}
if (mappingCalculator == null) {
mappingCalculator = new SemiAutoRebalancer();
}
break;
default:
break;
}