use of org.springframework.web.bind.annotation.RequestMapping 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 org.springframework.web.bind.annotation.RequestMapping in project jstorm by alibaba.
the class ClusterAPIController method zookeepers.
@RequestMapping("/zookeeper/summary")
public Map zookeepers(@PathVariable String clusterName) {
Map ret = new HashMap<>();
List<ZooKeeperEntity> zkServers = UIUtils.getZooKeeperEntities(clusterName);
ret.put("zookeepers", zkServers);
return ret;
}
use of org.springframework.web.bind.annotation.RequestMapping 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 org.springframework.web.bind.annotation.RequestMapping 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 org.springframework.web.bind.annotation.RequestMapping in project jstorm by alibaba.
the class LogController method search.
@RequestMapping(value = "/logSearch", method = RequestMethod.GET)
public String search(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "host", required = true) String host, @RequestParam(value = "port", required = true) String logServerPort, @RequestParam(value = "dir", required = true) String dir, @RequestParam(value = "file", required = true) String logName, @RequestParam(value = "key", required = false) String keyword, @RequestParam(value = "workerPort", required = false) String workerPort, @RequestParam(value = "tid", required = false) String topologyId, @RequestParam(value = "pos", required = false) String pos, @RequestParam(value = "caseIgnore", required = false) String caseIgnore, ModelMap model) {
clusterName = StringEscapeUtils.escapeHtml(clusterName);
topologyId = StringEscapeUtils.escapeHtml(topologyId);
if (StringUtils.isBlank(dir)) {
dir = ".";
}
String fullFile = getFullFile(dir, logName);
boolean _caseIgnore = !StringUtils.isBlank(caseIgnore);
model.addAttribute("keyword", keyword);
try {
// encode space and url characters
keyword = URLEncoder.encode(keyword, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
String url = String.format("http://%s:%s/logview?cmd=searchLog&file=%s&key=%s&offset=%s&case_ignore=%s", host, logServerPort, fullFile, keyword, JStormUtils.parseLong(pos, 0), _caseIgnore);
if (filterKeyword(model, keyword)) {
try {
HttpResponse httpResponse = httpGet(url);
String data = EntityUtils.toString(httpResponse.getEntity());
Map result = (Map) JStormUtils.from_json(data);
if (result == null) {
model.addAttribute("tip", data);
} else if (result.get("error") != null) {
model.addAttribute("tip", result.get("msg"));
} else {
model.addAttribute("matchResults", result.get("match_results"));
model.addAttribute("nextOffset", result.get("next_offset"));
model.addAttribute("numMatch", result.get("num_match"));
}
} catch (IOException e) {
e.printStackTrace();
model.addAttribute("tip", "Internal Error, can't get response from logview");
}
}
model.addAttribute("host", host);
model.addAttribute("clusterName", clusterName);
model.addAttribute("logServerPort", logServerPort);
model.addAttribute("topologyId", topologyId);
model.addAttribute("workerPort", workerPort);
model.addAttribute("dir", dir);
model.addAttribute("file", logName);
model.addAttribute("caseIgnore", _caseIgnore);
UIUtils.addTitleAttribute(model, "LogSearch");
return "logSearch";
}
Aggregations