Search in sources :

Example 1 with TopologyGraph

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

Aggregations

NimbusClient (backtype.storm.utils.NimbusClient)1 TopologyGraph (com.alibaba.jstorm.ui.model.graph.TopologyGraph)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1