Set<ResourceWorkerSlot> workers = assignment.getWorkers();
for (ResourceWorkerSlot worker : workers) {
for (Integer taskId : worker.getTasks()) {
TaskSummary taskSummary = new TaskSummary();
taskSummary.set_task_id(taskId);
taskSummary.set_component_id(taskToComponent.get(taskId));
taskSummary.set_host(worker.getHostname());
taskSummary.set_port(worker.getPort());
List<TaskError> errors = zkClusterState.task_errors(topologyId,
taskId);
List<ErrorInfo> newErrors = new ArrayList<ErrorInfo>();
if (errors != null) {
int size = errors.size();
for (int i = 0; i < size; i++) {
TaskError e = (TaskError) errors.get(i);
newErrors.add(new ErrorInfo(e.getError(), e
.getTimSecs()));
}
}
taskSummary.set_errors(newErrors);
TaskHeartbeat heartbeat = zkClusterState.task_heartbeat(
topologyId, taskId);
if (heartbeat == null) {
LOG.warn("Topology " + topologyId + " task " + taskId
+ " hasn't been started");
taskSummary.set_status(ConfigExtension.TASK_STATUS_STARTING);
} else {
taskSummary.set_uptime_secs(heartbeat.getUptimeSecs());
taskSummary.set_stats(heartbeat.getStats().getTaskStats());
taskSummary.set_status(ConfigExtension.TASK_STATUS_ACTIVE);
}
taskSummaries.put(taskId, taskSummary);
}
}