Search in sources :

Example 31 with NimbusClient

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;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with NimbusClient

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;
}
Also used : HashMap(java.util.HashMap) NimbusClient(backtype.storm.utils.NimbusClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with NimbusClient

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;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) ChartSeries(com.alibaba.jstorm.ui.model.graph.ChartSeries) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 34 with NimbusClient

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;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 35 with NimbusClient

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);
    }
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) ModelMap(org.springframework.ui.ModelMap) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

NimbusClient (backtype.storm.utils.NimbusClient)38 Map (java.util.Map)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 HashMap (java.util.HashMap)9 InvalidParameterException (java.security.InvalidParameterException)6 IOException (java.io.IOException)4 TException (org.apache.thrift.TException)4 ModelMap (org.springframework.ui.ModelMap)4 ClusterSummary (backtype.storm.generated.ClusterSummary)3 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)3 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)3 NimbusInfo (backtype.storm.nimbus.NimbusInfo)3 FileNotFoundException (java.io.FileNotFoundException)3 TTransportException (org.apache.thrift.transport.TTransportException)3 KillOptions (backtype.storm.generated.KillOptions)2 MetricInfo (backtype.storm.generated.MetricInfo)2 TopologyInfo (backtype.storm.generated.TopologyInfo)2 UITaskMetric (com.alibaba.jstorm.ui.model.UITaskMetric)2 UIWorkerMetric (com.alibaba.jstorm.ui.model.UIWorkerMetric)2 ChartSeries (com.alibaba.jstorm.ui.model.graph.ChartSeries)2