use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.
the class ClusterAPIController method supervisors.
@RequestMapping("/supervisor/summary")
public Map supervisors(@PathVariable String clusterName) {
Map ret;
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
ClusterSummary clusterSummary = client.getClient().getClusterInfo();
ret = new HashMap<>();
ret.put("supervisors", UIUtils.getSupervisorEntities(clusterSummary));
} 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 ClusterAPIController method workers.
@RequestMapping("/supervisor/{host:.+}")
public Map workers(@PathVariable String clusterName, @PathVariable String host, @RequestParam(value = "window", required = false) String window) {
Map<String, Object> ret = new HashMap<>();
int win = UIUtils.parseWindow(window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
SupervisorWorkers supervisorWorkers = client.getClient().getSupervisorWorkers(host);
ret.put("supervisor", new SupervisorEntity(supervisorWorkers.get_supervisor()));
//get worker summary
List<WorkerSummary> workerSummaries = supervisorWorkers.get_workers();
ret.put("workers", UIUtils.getWorkerEntities(workerSummaries));
Map<String, MetricInfo> workerMetricInfo = supervisorWorkers.get_workerMetric();
List<UIWorkerMetric> workerMetrics = UIMetricUtils.getWorkerMetrics(workerMetricInfo, workerSummaries, host, win);
ret.put("workerMetrics", workerMetrics);
} 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 summaryMetrics.
@RequestMapping("/metrics")
public Map summaryMetrics(@PathVariable String clusterName, @PathVariable String topology) {
//we only get the 60s window
int window = 60;
Map<String, Object> ret = new HashMap<>();
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
List<MetricInfo> infos = client.getClient().getMetrics(topology, MetaType.TOPOLOGY.getT());
List<ChartSeries> metrics = UIUtils.getChartSeries(infos, window);
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 tasks.
@RequestMapping("/task/{taskId}")
public Map tasks(@PathVariable String clusterName, @PathVariable String topology, @PathVariable Integer taskId, @RequestParam(value = "window", required = false) String window) {
Map<String, Object> ret = new HashMap<>();
int win = UIUtils.parseWindow(window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology);
String component = null;
String type = null;
for (ComponentSummary summary : topologyInfo.get_components()) {
if (summary.get_taskIds().contains(taskId)) {
component = summary.get_name();
type = summary.get_type();
}
}
ret.put("topologyId", topology);
ret.put("topologyName", topologyInfo.get_topology().get_name());
ret.put("component", component);
TaskEntity task = UIUtils.getTaskEntity(topologyInfo.get_tasks(), taskId);
task.setComponent(component);
task.setType(type);
ret.put("task", task);
List<MetricInfo> taskStreamMetrics = client.getClient().getTaskAndStreamMetrics(topology, taskId);
UITaskMetric taskMetric = UIMetricUtils.getTaskMetric(taskStreamMetrics, component, taskId, win);
ret.put("taskMetric", taskMetric);
List<UIStreamMetric> streamMetrics = UIMetricUtils.getStreamMetrics(taskStreamMetrics, component, taskId, win);
ret.put("streamMetrics", streamMetrics);
} 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 UIUtils method getTopologyConf.
public static Map<String, Object> getTopologyConf(String clusterName, String topologyId) {
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(clusterName);
String jsonConf = client.getClient().getTopologyConf(topologyId);
Map<String, Object> topologyConf = (Map<String, Object>) Utils.from_json(jsonConf);
return topologyConf;
} catch (Exception e) {
NimbusClientManager.removeClient(clusterName);
LOG.error(e.getMessage(), e);
return getNimbusConf(clusterName);
}
}
Aggregations