use of org.apache.helix.controller.rebalancer.MaintenanceRebalancer in project helix by apache.
the class BestPossibleStateCalcStage method getRebalancer.
private Rebalancer getRebalancer(IdealState idealState, String resourceName, boolean isMaintenanceModeEnabled) {
Rebalancer customizedRebalancer = null;
String rebalancerClassName = idealState.getRebalancerClassName();
if (rebalancerClassName != null) {
logger.debug("resource " + resourceName + " use idealStateRebalancer " + rebalancerClassName);
try {
customizedRebalancer = Rebalancer.class.cast(HelixUtil.loadClass(getClass(), rebalancerClassName).newInstance());
} catch (Exception e) {
logger.error("Exception while invoking custom rebalancer class:" + rebalancerClassName, e);
}
}
Rebalancer rebalancer = null;
switch(idealState.getRebalanceMode()) {
case FULL_AUTO:
if (isMaintenanceModeEnabled) {
rebalancer = new MaintenanceRebalancer();
} else {
if (customizedRebalancer != null) {
rebalancer = customizedRebalancer;
} else {
rebalancer = new AutoRebalancer();
}
}
break;
case SEMI_AUTO:
rebalancer = new SemiAutoRebalancer();
break;
case CUSTOMIZED:
rebalancer = new CustomRebalancer();
break;
case USER_DEFINED:
case TASK:
rebalancer = customizedRebalancer;
break;
default:
logger.error("Fail to find the rebalancer, invalid rebalance mode " + idealState.getRebalanceMode());
break;
}
return rebalancer;
}
Aggregations