@Override
public TopologyMetricInfo getTopologyMetric(String topologyId) throws NotAliveException, TException{
LOG.debug("Nimbus service handler, getTopologyMetric, topology ID: " + topologyId);
TopologyMetricInfo topologyMetricInfo = new TopologyMetricInfo();
StormClusterState clusterState = data.getStormClusterState();
topologyMetricInfo.set_topology_id(topologyId);
try {
//update task metrics list
Map<Integer, TaskInfo> taskInfoList = clusterState.task_info_list(topologyId);
List<TaskMetricInfo> taskMetricList = clusterState.get_task_metric_list(topologyId);
for(TaskMetricInfo taskMetricInfo : taskMetricList) {
TaskMetricData taskMetricData = new TaskMetricData();
NimbusUtils.updateTaskMetricData(taskMetricData, taskMetricInfo);
TaskInfo taskInfo = taskInfoList.get(Integer.parseInt(taskMetricInfo.getTaskId()));
String componentId = taskInfo.getComponentId();
taskMetricData.set_component_id(componentId);
topologyMetricInfo.add_to_task_metric_list(taskMetricData);
}
//update worker metrics list
List<WorkerMetricInfo> workerMetricList = clusterState.get_worker_metric_list(topologyId);
for(WorkerMetricInfo workerMetricInfo : workerMetricList) {
WorkerMetricData workerMetricData = new WorkerMetricData();
NimbusUtils.updateWorkerMetricData(workerMetricData, workerMetricInfo);
topologyMetricInfo.add_to_worker_metric_list(workerMetricData);
}
} catch(Exception e) {
String errMsg = "Failed to get topology Metric Data " + topologyId;
LOG.error(errMsg, e);