MessageSelectionStageOutput output = new MessageSelectionStageOutput();
for (String resourceName : resourceMap.keySet()) {
Resource resource = resourceMap.get(resourceName);
StateModelDefinition stateModelDef = cache.getStateModelDef(resource.getStateModelDefRef());
Map<String, Integer> stateTransitionPriorities = getStateTransitionPriorityMap(stateModelDef);
IdealState idealState = cache.getIdealState(resourceName);
Map<String, Bounds> stateConstraints =
computeStateConstraints(stateModelDef, idealState, cache);
for (Partition partition : resource.getPartitions()) {
List<Message> messages = messageGenOutput.getMessages(resourceName, partition);
List<Message> selectedMessages =
selectMessages(cache.getLiveInstances(),
currentStateOutput.getCurrentStateMap(resourceName, partition),
currentStateOutput.getPendingStateMap(resourceName, partition), messages,
stateConstraints, stateTransitionPriorities, stateModelDef.getInitialState());
output.addMessages(resourceName, partition, selectedMessages);
}
}
event.addAttribute(AttributeName.MESSAGES_SELECTED.toString(), output);
}