Search in sources :

Example 1 with ChartSeries

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

Example 2 with ChartSeries

use of com.alibaba.jstorm.ui.model.graph.ChartSeries 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)

Aggregations

NimbusClient (backtype.storm.utils.NimbusClient)2 ChartSeries (com.alibaba.jstorm.ui.model.graph.ChartSeries)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1