use of com.alibaba.jstorm.ui.model.UITaskMetric in project jstorm by alibaba.
the class TaskController method show.
@RequestMapping(value = "/task", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "topology", required = true) String topology_id, @RequestParam(value = "component", required = true) String component, @RequestParam(value = "id", required = true) String task_id, @RequestParam(value = "win", required = false) String win, ModelMap model) {
clusterName = StringEscapeUtils.escapeHtml(clusterName);
topology_id = StringEscapeUtils.escapeHtml(topology_id);
long start = System.currentTimeMillis();
int window = UIUtils.parseWindow(win);
UIUtils.addWindowAttribute(model, window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
//get task entity
TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology_id);
int id = JStormUtils.parseInt(task_id);
TaskEntity task = UIUtils.getTaskEntity(topologyInfo.get_tasks(), id);
task.setComponent(component);
model.addAttribute("task", task);
//get task metric
List<MetricInfo> taskStreamMetrics = client.getClient().getTaskAndStreamMetrics(topology_id, id);
// System.out.println("taskMetrics size:"+getSize(taskMetrics));
UITaskMetric taskMetric = UIMetricUtils.getTaskMetric(taskStreamMetrics, component, id, window);
model.addAttribute("taskMetric", taskMetric);
model.addAttribute("taskHead", UIMetricUtils.sortHead(taskMetric, UITaskMetric.HEAD));
//get stream metric
List<UIStreamMetric> streamData = UIMetricUtils.getStreamMetrics(taskStreamMetrics, component, id, window);
model.addAttribute("streamData", streamData);
model.addAttribute("streamHead", UIMetricUtils.sortHead(streamData, UIStreamMetric.HEAD));
} catch (NotAliveException nae) {
model.addAttribute("flush", String.format("The topology: %s is dead", topology_id));
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
model.addAttribute("clusterName", clusterName);
model.addAttribute("topologyId", topology_id);
model.addAttribute("compName", component);
model.addAttribute("page", "task");
UIUtils.addTitleAttribute(model, "Task Summary");
LOG.info("task page show cost:{}ms", System.currentTimeMillis() - start);
return "task";
}
use of com.alibaba.jstorm.ui.model.UITaskMetric in project jstorm by alibaba.
the class ComponentController method show.
@RequestMapping(value = "/component", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "topology", required = true) String topology_id, @RequestParam(value = "component", required = true) String component, @RequestParam(value = "win", required = false) String win, ModelMap model) {
clusterName = StringEscapeUtils.escapeHtml(clusterName);
topology_id = StringEscapeUtils.escapeHtml(topology_id);
long start = System.currentTimeMillis();
int window = UIUtils.parseWindow(win);
UIUtils.addWindowAttribute(model, window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
//get Component Metric
TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology_id);
MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
// List<MetricInfo> componentMetrics = client.getClient().getMetrics(topology_id, MetaType.COMPONENT.getT());
UIComponentMetric componentMetric = UIMetricUtils.getComponentMetric(componentMetrics, window, component, topologyInfo.get_components());
model.addAttribute("comp", componentMetric);
model.addAttribute("compHead", UIMetricUtils.sortHead(componentMetric, UIComponentMetric.HEAD));
//get Task Stat
model.addAttribute("tasks", UIUtils.getTaskEntities(topologyInfo, component));
//get Task metrics
// MetricInfo taskMetrics = topologyInfo.get_metrics().get_taskMetric();
MetricInfo taskMetrics = client.getClient().getTaskMetrics(topology_id, component);
// System.out.println("taskMetrics:" + taskMetrics);
List<UITaskMetric> taskData = UIMetricUtils.getTaskMetrics(taskMetrics, component, window);
model.addAttribute("taskData", taskData);
model.addAttribute("taskHead", UIMetricUtils.sortHead(taskData, UITaskMetric.HEAD));
} catch (NotAliveException nae) {
model.addAttribute("flush", String.format("The topology: %s is dead.", topology_id));
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
// page information
model.addAttribute("clusterName", clusterName);
model.addAttribute("topologyId", topology_id);
model.addAttribute("compName", component);
model.addAttribute("page", "component");
model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName));
UIUtils.addTitleAttribute(model, "Component Summary");
try {
String topologyName = Common.topologyIdToName(topology_id);
model.addAttribute("topologyName", topologyName);
} catch (InvalidTopologyException e) {
e.printStackTrace();
}
LOG.info("component page show cost:{}ms", System.currentTimeMillis() - start);
return "component";
}
Aggregations