use of com.alibaba.jstorm.ui.model.SupervisorEntity in project jstorm by alibaba.
the class SupervisorController method show.
@RequestMapping(value = "/supervisor", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "host", required = true) String host, @RequestParam(value = "win", required = false) String win, ModelMap model) {
clusterName = StringEscapeUtils.escapeHtml(clusterName);
long start = System.currentTimeMillis();
host = NetWorkUtils.host2Ip(host);
int window = UIUtils.parseWindow(win);
UIUtils.addWindowAttribute(model, window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
//get supervisor summary
SupervisorWorkers supervisorWorkers = client.getClient().getSupervisorWorkers(host);
model.addAttribute("supervisor", new SupervisorEntity(supervisorWorkers.get_supervisor()));
//get worker summary
List<WorkerSummary> workerSummaries = supervisorWorkers.get_workers();
model.addAttribute("workerSummary", UIUtils.getWorkerEntities(workerSummaries));
//get worker metrics
Map<String, MetricInfo> workerMetricInfo = supervisorWorkers.get_workerMetric();
List<UIWorkerMetric> workerMetrics = UIMetricUtils.getWorkerMetrics(workerMetricInfo, workerSummaries, host, window);
// System.out.println("workerMetricInfo:"+workerMetricInfo);
model.addAttribute("workerMetrics", workerMetrics);
model.addAttribute("workerHead", UIMetricUtils.sortHead(workerMetrics, UIWorkerMetric.HEAD));
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
// page information
model.addAttribute("clusterName", clusterName);
model.addAttribute("host", host);
model.addAttribute("page", "supervisor");
model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName));
UIUtils.addTitleAttribute(model, "Supervisor Summary");
LOG.info("supervisor page show cost:{}ms", System.currentTimeMillis() - start);
return "supervisor";
}
Aggregations