int numOfTopologies = clusterInfo.get_topologies_size();
sb.append("In total there is ").append(numOfTopologies).append(" topologies.\n");
Iterator<TopologySummary> topologyIter = clusterInfo.get_topologies_iterator();
while(topologyIter.hasNext()){
TopologySummary topologySummary= topologyIter.next();
//print out basic information about topologies
String topologyName = topologySummary.get_name();
sb.append("For topology ").append(topologyName).append(":\n");
int numTasks = topologySummary.get_num_tasks();
sb.append(numTasks).append(" tasks, ");
int numWorkers = topologySummary.get_num_workers();
sb.append(numWorkers).append(" workers, ");
int uptimeSecs = topologySummary.get_uptime_secs();
sb.append(uptimeSecs).append(" uptime seconds.\n");
String topologyID = topologySummary.get_id();
String topologyConf = client.getTopologyConf(topologyID);
sb.append("Topology configuration is \n");
sb.append(topologyConf);
sb.append("\n");
TopologyInfo topologyInfo = client.getTopologyInfo(topologyID);
//print more about each task
Iterator<ExecutorSummary> execIter = topologyInfo.get_executors_iterator();
boolean globalFailed = false;
while(execIter.hasNext()){
ExecutorSummary execSummary = execIter.next();
String componentId = execSummary.get_component_id();
sb.append("component_id:").append(componentId).append(", ");
ExecutorInfo execInfo = execSummary.get_executor_info();
int taskStart = execInfo.get_task_start();
int taskEnd = execInfo.get_task_end();
sb.append("task_id(s) for this executor:").append(taskStart).append("-").append(taskEnd).append(", ");
String host = execSummary.get_host();
sb.append("host:").append(host).append(", ");
int port = execSummary.get_port();
sb.append("port:").append(port).append(", ");
int uptime = execSummary.get_uptime_secs();
sb.append("uptime:").append(uptime).append("\n");
sb.append("\n");
//printing failing statistics, if there are failed tuples
ExecutorStats es = execSummary.get_stats();
if(es == null){
sb.append("No info about failed tuples\n");
}else{
ExecutorSpecificStats stats = es.get_specific();
boolean isEmpty;
Object objFailed;
if(stats.is_set_spout()){
Map<String, Map<String, Long>> failed = stats.get_spout().get_failed();
objFailed = failed;
isEmpty = isEmptyMapMap(failed);
}else{
Map<String, Map<GlobalStreamId, Long>> failed = stats.get_bolt().get_failed();
objFailed = failed;
isEmpty = isEmptyMapMap(failed);
}
if(!isEmpty){
sb.append("ERROR: There are some failed tuples: ").append(objFailed).append("\n");
globalFailed = true;
}
}
}
//is there at least one component where something failed
if(!globalFailed){
sb.append("OK: No tuples failed so far.\n");
}else{
sb.append("ERROR: Some tuples failed!\n");
}
//print topology errors
Map<String, List<ErrorInfo>> errors = topologyInfo.get_errors();
if(!isEmptyMap(errors)){
sb.append("ERROR: There are some errors in topology: ").append(errors).append("\n");
}else{
sb.append("OK: No errors in the topology.\n");
}
boolean withAckers = getAckMode(topologyInfo);
int topologyUptime = topologySummary.get_uptime_secs();
sb.append(writeStatistics(topologyInfo, topologyUptime, withAckers));
sb.append(writeBoltLatencies(topologyInfo, topologyUptime, withAckers));
}
sb.append("\n\n");