use of backtype.storm.utils.NimbusClient 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";
}
use of backtype.storm.utils.NimbusClient 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 backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class TopologyController method show.
@RequestMapping(value = "/topology", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String cluster, @RequestParam(value = "id") String id, @RequestParam(value = "win", required = false) String win, ModelMap model) {
cluster = StringEscapeUtils.escapeHtml(cluster);
id = StringEscapeUtils.escapeHtml(id);
long start = System.currentTimeMillis();
LOG.info("request topology info for cluster name: " + cluster + " id:" + id);
int window = UIUtils.parseWindow(win);
UIUtils.addWindowAttribute(model, window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(cluster);
TopologyInfo topologyInfo = client.getClient().getTopologyInfo(id);
// System.out.println("topologyinfo worker metric:" + topologyInfo.get_metrics().get_workerMetric());
model.addAttribute("topology", JStormUtils.thriftToMap(topologyInfo.get_topology()));
// model.addAttribute("tasks", getTaskEntities(topologyInfo)); //remove tasks stat
model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(cluster));
MetricInfo topologyMetrics = topologyInfo.get_metrics().get_topologyMetric();
// List<MetricInfo> topologyMetrics = client.getClient().getMetrics(id, MetaType.TOPOLOGY.getT());
// System.out.println("topologyMetrics:" + topologyMetrics);
UISummaryMetric topologyData = UIMetricUtils.getSummaryMetrics(topologyMetrics, window);
model.addAttribute("topologyData", topologyData);
model.addAttribute("topologyHead", UIMetricUtils.sortHead(topologyData, UISummaryMetric.HEAD));
MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
// List<MetricInfo> componentMetrics = client.getClient().getMetrics(id, MetaType.COMPONENT.getT());
// System.out.println("componentMetrics:" + componentMetrics);
List<UIUserDefinedMetric> userDefinedMetrics = Lists.newArrayList();
List<UIComponentMetric> componentData = UIMetricUtils.getComponentMetrics(componentMetrics, window, topologyInfo.get_components(), userDefinedMetrics);
model.addAttribute("componentData", componentData);
model.addAttribute("componentHead", UIMetricUtils.sortHead(componentData, UIComponentMetric.HEAD));
model.addAttribute("userDefinedMetrics", userDefinedMetrics);
// System.out.println("componentHead:" + BasicMetric.sortHead(componentData));
MetricInfo workerMetrics = topologyInfo.get_metrics().get_workerMetric();
// List<MetricInfo> workerMetrics = client.getClient().getMetrics(id, MetaType.WORKER.getT());
// System.out.println("workerMetrics:" + workerMetrics);
List<UIWorkerMetric> workerData = UIMetricUtils.getWorkerMetrics(workerMetrics, id, window);
model.addAttribute("workerData", workerData);
model.addAttribute("workerHead", UIMetricUtils.sortHead(workerData, UIWorkerMetric.HEAD));
List<TaskEntity> taskData = UIUtils.getTaskEntities(topologyInfo);
model.addAttribute("taskData", taskData);
} catch (NotAliveException nae) {
model.addAttribute("flush", String.format("The topology: %s is dead.", id));
} catch (Exception e) {
NimbusClientManager.removeClient(cluster);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
model.addAttribute("page", "topology");
model.addAttribute("clusterName", cluster);
UIUtils.addTitleAttribute(model, "Topology Summary");
LOG.info("topology page show cost:{}ms", System.currentTimeMillis() - start);
return "topology";
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class NimbusClientManager method getNimbusClient.
public static NimbusClient getNimbusClient(String clusterName) throws Exception {
Map conf = UIUtils.readUiConfig();
NimbusClient client = clientManager.get(clusterName);
if (client != null) {
try {
client.getClient().getVersion();
LOG.info("get Nimbus Client from clientManager");
} catch (Exception e) {
LOG.info("Nimbus has been restarted, it begin to reconnect");
client = null;
}
}
if (client == null) {
conf = UIUtils.resetZKConfig(conf, clusterName);
client = NimbusClient.getConfiguredClient(conf);
clientManager.put(clusterName, client);
}
return client;
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class UIUtils method getNimbusConf.
public static Map<String, Object> getNimbusConf(String clusterName) {
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
String jsonConf = client.getClient().getNimbusConf();
Map<String, Object> nimbusConf = (Map<String, Object>) Utils.from_json(jsonConf);
return nimbusConf;
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
return UIUtils.readUiConfig();
}
}
Aggregations