use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class ClusterAPIController method metrics.
@RequestMapping("/metrics")
public Map metrics(@PathVariable String clusterName) {
//we only get the 60s window
int window = 60;
Map ret;
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
List<MetricInfo> infos = client.getClient().getMetrics(JStormMetrics.CLUSTER_METRIC_KEY, MetaType.TOPOLOGY.getT());
List<ChartSeries> metrics = UIUtils.getChartSeries(infos, window);
ret = new HashMap<>();
ret.put("metrics", metrics);
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
ret = UIUtils.exceptionJson(e);
LOG.error(e.getMessage(), e);
}
return ret;
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class TopologyAPIController method graph.
@RequestMapping("/graph")
public Map graph(@PathVariable String clusterName, @PathVariable String topology) {
Map<String, Object> result = new HashMap<>();
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
StormTopology stormTopology = client.getClient().getTopology(topology);
int size = componentSize(stormTopology);
if (size < 100) {
List<MetricInfo> componentMetrics = client.getClient().getMetrics(topology, MetaType.COMPONENT.getT());
TopologyGraph graph = UIUtils.getTopologyGraph(stormTopology, componentMetrics);
result.put("graph", graph);
} else {
result.put("error", "too many components, please check your topology first!");
}
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
result = UIUtils.exceptionJson(e);
}
return result;
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class ClusterController method show.
@RequestMapping(value = "/cluster", method = RequestMethod.GET)
public String show(@RequestParam(value = "name", required = true) String name, ModelMap model) {
name = StringEscapeUtils.escapeHtml(name);
long start = System.currentTimeMillis();
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(name);
ClusterSummary clusterSummary = client.getClient().getClusterInfo();
model.addAttribute("nimbus", UIUtils.getNimbusEntities(clusterSummary));
model.addAttribute("topologies", UIUtils.getTopologyEntities(clusterSummary));
model.addAttribute("supervisors", UIUtils.getSupervisorEntities(clusterSummary));
model.addAttribute("zkServers", UIUtils.getZooKeeperEntities(name));
List<MetricInfo> clusterMetrics = client.getClient().getMetrics(JStormMetrics.CLUSTER_METRIC_KEY, MetaType.TOPOLOGY.getT());
UISummaryMetric clusterData = UIMetricUtils.getSummaryMetrics(clusterMetrics, AsmWindow.M1_WINDOW);
model.addAttribute("clusterData", clusterData);
model.addAttribute("clusterHead", UIMetricUtils.sortHead(clusterData, UISummaryMetric.HEAD));
//update cluster cache
ClusterEntity ce = UIUtils.getClusterEntity(clusterSummary, name);
model.addAttribute("cluster", ce);
UIUtils.clustersCache.put(name, ce);
} catch (Exception e) {
NimbusClientManager.removeClient(name);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
//set nimbus port and supervisor port , if necessary
model.addAttribute("nimbusPort", UIUtils.getNimbusPort(name));
model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(name));
model.addAttribute("clusterName", name);
model.addAttribute("page", "cluster");
UIUtils.addTitleAttribute(model, "Cluster Summary");
LOG.info("cluster page show cost:{}ms", System.currentTimeMillis() - start);
return "cluster";
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class LogController method deepSearch.
@RequestMapping(value = "/deepSearch", method = RequestMethod.GET)
public String deepSearch(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "tid", required = true) String topologyId, @RequestParam(value = "key", required = false) String keyword, @RequestParam(value = "caseIgnore", required = false) String caseIgnore, ModelMap model) {
clusterName = StringEscapeUtils.escapeHtml(clusterName);
topologyId = StringEscapeUtils.escapeHtml(topologyId);
boolean _caseIgnore = !StringUtils.isBlank(caseIgnore);
int port = UIUtils.getSupervisorPort(clusterName);
model.addAttribute("keyword", keyword);
List<Future<?>> futures = new ArrayList<>();
ConcurrentLinkedQueue<Map> result = new ConcurrentLinkedQueue<>();
if (filterKeyword(model, keyword)) {
NimbusClient client = null;
try {
// encode space and url characters
keyword = URLEncoder.encode(keyword, "UTF-8");
client = NimbusClientManager.getNimbusClient(clusterName);
TopologyInfo info = client.getClient().getTopologyInfo(topologyId);
String topologyName = info.get_topology().get_name();
List<UIWorkerMetric> workerData = UIMetricUtils.getWorkerMetrics(info.get_metrics().get_workerMetric(), topologyId, 60);
String dir = "." + File.separator + topologyName;
for (UIWorkerMetric metric : workerData) {
String logFile = topologyName + "-worker-" + metric.getPort() + ".log";
String url = String.format("http://%s:%s/logview?cmd=searchLog&file=%s&key=%s&offset=%s&case_ignore=%s", metric.getHost(), port, getFullFile(dir, logFile), keyword, 0, _caseIgnore);
futures.add(_backround.submit(new SearchRequest(url, metric.getHost(), metric.getPort(), dir, logFile, result)));
}
JStormServerUtils.checkFutures(futures);
model.addAttribute("result", result);
} catch (NotAliveException nae) {
model.addAttribute("tip", String.format("The topology: %s is dead.", topologyId));
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
}
model.addAttribute("clusterName", clusterName);
model.addAttribute("topologyId", topologyId);
model.addAttribute("logServerPort", port);
model.addAttribute("caseIgnore", _caseIgnore);
UIUtils.addTitleAttribute(model, "DeepSearch");
return "deepSearch";
}
use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class NettyController method show.
@RequestMapping(value = "/netty", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "topology", required = true) String topology_id, @RequestParam(value = "host", required = true) String host, @RequestParam(value = "page", required = false) String page, @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);
int _page = JStormUtils.parseInt(page, 1);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
//get netty metrics, page is from 1
MetricInfo nettyMetric = client.getClient().getPagingNettyMetrics(topology_id, host, _page);
// System.out.println("nettyMetric:"+nettyMetric);
List<UINettyMetric> nettyData = getNettyData(nettyMetric, host, window);
model.addAttribute("nettyMetrics", nettyData);
model.addAttribute("nettyHead", UIMetricUtils.sortHead(nettyData, UINettyMetric.HEAD));
int size = client.getClient().getNettyMetricSizeByHost(topology_id, host);
// System.out.println("netty size:"+size);
int pageSize = (size + PAGE_SIZE - 1) / PAGE_SIZE;
model.addAttribute("pageSize", pageSize);
model.addAttribute("curPage", _page);
if (size == 0) {
//check whether netty metric is turn off
Map conf = UIUtils.getTopologyConf(clusterName, topology_id);
boolean enable = MetricUtils.isEnableNettyMetrics(conf);
if (!enable) {
model.addAttribute("flush", "the netty metrics is not enabled");
}
}
} 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", "netty");
model.addAttribute("topologyId", topology_id);
model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName));
UIUtils.addTitleAttribute(model, "Netty Summary");
LOG.info("netty page show cost:{}ms", System.currentTimeMillis() - start);
return "netty";
}
Aggregations