}
@Override
public ResourceAssignment computeResourceMapping(RebalancerConfig rebalancerConfig,
Cluster cluster, ResourceCurrentState currentState) {
CustomRebalancerContext config =
rebalancerConfig.getRebalancerContext(CustomRebalancerContext.class);
StateModelDefinition stateModelDef =
cluster.getStateModelMap().get(config.getStateModelDefId());
if (LOG.isDebugEnabled()) {
LOG.debug("Processing resource:" + config.getResourceId());
}
ResourceAssignment partitionMapping = new ResourceAssignment(config.getResourceId());
for (PartitionId partition : config.getPartitionSet()) {
Map<ParticipantId, State> currentStateMap =
currentState.getCurrentStateMap(config.getResourceId(), partition);
Set<ParticipantId> disabledInstancesForPartition =
ConstraintBasedAssignment.getDisabledParticipants(cluster.getParticipantMap(), partition);
Map<ParticipantId, State> bestStateForPartition =
ConstraintBasedAssignment.computeCustomizedBestStateForPartition(cluster
.getLiveParticipantMap().keySet(), stateModelDef, config.getPreferenceMap(partition),
currentStateMap, disabledInstancesForPartition);
partitionMapping.addReplicaMap(partition, bestStateForPartition);
}
return partitionMapping;
}