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);
List<ParticipantId> preferenceList =
ConstraintBasedAssignment.getPreferenceList(cluster, partition,
config.getPreferenceList(partition));
Map<State, String> upperBounds =
ConstraintBasedAssignment.stateConstraints(stateModelDef, config.getResourceId(),
cluster.getConfig());
Map<ParticipantId, State> bestStateForPartition =
ConstraintBasedAssignment.computeAutoBestStateForPartition(upperBounds, cluster
.getLiveParticipantMap().keySet(), stateModelDef, preferenceList, currentStateMap,
disabledInstancesForPartition);
partitionMapping.addReplicaMap(partition, bestStateForPartition);
}
return partitionMapping;
}