if (controllerMsgUpdates.size() > 0) {
for (String controllerMsgId : controllerMsgUpdates.keySet()) {
PropertyKey controllerStatusUpdateKey =
keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), controllerMsgId);
StatusUpdate controllerStatusUpdate = accessor.getProperty(controllerStatusUpdateKey);
for (String taskPartitionName : controllerMsgUpdates.get(controllerMsgId).keySet()) {
Map<String, String> result = new HashMap<String, String>();
result.put("Result", controllerMsgUpdates.get(controllerMsgId).get(taskPartitionName));
controllerStatusUpdate.getRecord().setMapField(
"MessageResult "
+ taskQueueIdealState.getRecord().getMapField(taskPartitionName)
.get(Message.Attributes.TGT_NAME.toString())
+ " "
+ taskPartitionName
+ " "
+ taskQueueIdealState.getRecord().getMapField(taskPartitionName)
.get(Message.Attributes.MSG_ID.toString()), result);
}
// All done for the scheduled tasks that came from controllerMsgId, add summary for it
if (controllerMsgUpdates.get(controllerMsgId).size() == controllerMsgIdCountMap.get(
controllerMsgId).intValue()) {
int finishedTasksNum = 0;
int completedTasksNum = 0;
for (String key : controllerStatusUpdate.getRecord().getMapFields().keySet()) {
if (key.startsWith("MessageResult ")) {
finishedTasksNum++;
}
if (controllerStatusUpdate.getRecord().getMapField(key).get("Result") != null) {
if (controllerStatusUpdate.getRecord().getMapField(key).get("Result")
.equalsIgnoreCase("COMPLETED")) {
completedTasksNum++;
}
}
}
Map<String, String> summary = new TreeMap<String, String>();
summary.put("TotalMessages:", "" + finishedTasksNum);
summary.put("CompletedMessages", "" + completedTasksNum);
controllerStatusUpdate.getRecord().setMapField("Summary", summary);
}
// Update the statusUpdate of controllerMsgId
accessor.updateProperty(controllerStatusUpdateKey, controllerStatusUpdate);
}
}