Search in sources :

Example 16 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class SupervisorController method show.

@RequestMapping(value = "/supervisor", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "host", required = true) String host, @RequestParam(value = "win", required = false) String win, ModelMap model) {
    clusterName = StringEscapeUtils.escapeHtml(clusterName);
    long start = System.currentTimeMillis();
    host = NetWorkUtils.host2Ip(host);
    int window = UIUtils.parseWindow(win);
    UIUtils.addWindowAttribute(model, window);
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        //get supervisor summary
        SupervisorWorkers supervisorWorkers = client.getClient().getSupervisorWorkers(host);
        model.addAttribute("supervisor", new SupervisorEntity(supervisorWorkers.get_supervisor()));
        //get worker summary
        List<WorkerSummary> workerSummaries = supervisorWorkers.get_workers();
        model.addAttribute("workerSummary", UIUtils.getWorkerEntities(workerSummaries));
        //get worker metrics
        Map<String, MetricInfo> workerMetricInfo = supervisorWorkers.get_workerMetric();
        List<UIWorkerMetric> workerMetrics = UIMetricUtils.getWorkerMetrics(workerMetricInfo, workerSummaries, host, window);
        //            System.out.println("workerMetricInfo:"+workerMetricInfo);
        model.addAttribute("workerMetrics", workerMetrics);
        model.addAttribute("workerHead", UIMetricUtils.sortHead(workerMetrics, UIWorkerMetric.HEAD));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        LOG.error(e.getMessage(), e);
        UIUtils.addErrorAttribute(model, e);
    }
    // page information
    model.addAttribute("clusterName", clusterName);
    model.addAttribute("host", host);
    model.addAttribute("page", "supervisor");
    model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName));
    UIUtils.addTitleAttribute(model, "Supervisor Summary");
    LOG.info("supervisor page show cost:{}ms", System.currentTimeMillis() - start);
    return "supervisor";
}
Also used : UIWorkerMetric(com.alibaba.jstorm.ui.model.UIWorkerMetric) NimbusClient(backtype.storm.utils.NimbusClient) SupervisorEntity(com.alibaba.jstorm.ui.model.SupervisorEntity) WorkerSummary(backtype.storm.generated.WorkerSummary) MetricInfo(backtype.storm.generated.MetricInfo) SupervisorWorkers(backtype.storm.generated.SupervisorWorkers) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class TaskController method show.

@RequestMapping(value = "/task", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "topology", required = true) String topology_id, @RequestParam(value = "component", required = true) String component, @RequestParam(value = "id", required = true) String task_id, @RequestParam(value = "win", required = false) String win, ModelMap model) {
    clusterName = StringEscapeUtils.escapeHtml(clusterName);
    topology_id = StringEscapeUtils.escapeHtml(topology_id);
    long start = System.currentTimeMillis();
    int window = UIUtils.parseWindow(win);
    UIUtils.addWindowAttribute(model, window);
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        //get task entity
        TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology_id);
        int id = JStormUtils.parseInt(task_id);
        TaskEntity task = UIUtils.getTaskEntity(topologyInfo.get_tasks(), id);
        task.setComponent(component);
        model.addAttribute("task", task);
        //get task metric
        List<MetricInfo> taskStreamMetrics = client.getClient().getTaskAndStreamMetrics(topology_id, id);
        //            System.out.println("taskMetrics size:"+getSize(taskMetrics));
        UITaskMetric taskMetric = UIMetricUtils.getTaskMetric(taskStreamMetrics, component, id, window);
        model.addAttribute("taskMetric", taskMetric);
        model.addAttribute("taskHead", UIMetricUtils.sortHead(taskMetric, UITaskMetric.HEAD));
        //get stream metric
        List<UIStreamMetric> streamData = UIMetricUtils.getStreamMetrics(taskStreamMetrics, component, id, window);
        model.addAttribute("streamData", streamData);
        model.addAttribute("streamHead", UIMetricUtils.sortHead(streamData, UIStreamMetric.HEAD));
    } catch (NotAliveException nae) {
        model.addAttribute("flush", String.format("The topology: %s is dead", topology_id));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        LOG.error(e.getMessage(), e);
        UIUtils.addErrorAttribute(model, e);
    }
    model.addAttribute("clusterName", clusterName);
    model.addAttribute("topologyId", topology_id);
    model.addAttribute("compName", component);
    model.addAttribute("page", "task");
    UIUtils.addTitleAttribute(model, "Task Summary");
    LOG.info("task page show cost:{}ms", System.currentTimeMillis() - start);
    return "task";
}
Also used : TaskEntity(com.alibaba.jstorm.ui.model.TaskEntity) UIStreamMetric(com.alibaba.jstorm.ui.model.UIStreamMetric) NimbusClient(backtype.storm.utils.NimbusClient) UITaskMetric(com.alibaba.jstorm.ui.model.UITaskMetric) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class TopologyController method show.

@RequestMapping(value = "/topology", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String cluster, @RequestParam(value = "id") String id, @RequestParam(value = "win", required = false) String win, ModelMap model) {
    cluster = StringEscapeUtils.escapeHtml(cluster);
    id = StringEscapeUtils.escapeHtml(id);
    long start = System.currentTimeMillis();
    LOG.info("request topology info for cluster name: " + cluster + " id:" + id);
    int window = UIUtils.parseWindow(win);
    UIUtils.addWindowAttribute(model, window);
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(cluster);
        TopologyInfo topologyInfo = client.getClient().getTopologyInfo(id);
        //            System.out.println("topologyinfo worker metric:" + topologyInfo.get_metrics().get_workerMetric());
        model.addAttribute("topology", JStormUtils.thriftToMap(topologyInfo.get_topology()));
        //            model.addAttribute("tasks", getTaskEntities(topologyInfo));       //remove tasks stat
        model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(cluster));
        MetricInfo topologyMetrics = topologyInfo.get_metrics().get_topologyMetric();
        //            List<MetricInfo> topologyMetrics = client.getClient().getMetrics(id, MetaType.TOPOLOGY.getT());
        //            System.out.println("topologyMetrics:" + topologyMetrics);
        UISummaryMetric topologyData = UIMetricUtils.getSummaryMetrics(topologyMetrics, window);
        model.addAttribute("topologyData", topologyData);
        model.addAttribute("topologyHead", UIMetricUtils.sortHead(topologyData, UISummaryMetric.HEAD));
        MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
        //            List<MetricInfo> componentMetrics = client.getClient().getMetrics(id, MetaType.COMPONENT.getT());
        //            System.out.println("componentMetrics:" + componentMetrics);
        List<UIUserDefinedMetric> userDefinedMetrics = Lists.newArrayList();
        List<UIComponentMetric> componentData = UIMetricUtils.getComponentMetrics(componentMetrics, window, topologyInfo.get_components(), userDefinedMetrics);
        model.addAttribute("componentData", componentData);
        model.addAttribute("componentHead", UIMetricUtils.sortHead(componentData, UIComponentMetric.HEAD));
        model.addAttribute("userDefinedMetrics", userDefinedMetrics);
        //            System.out.println("componentHead:" + BasicMetric.sortHead(componentData));
        MetricInfo workerMetrics = topologyInfo.get_metrics().get_workerMetric();
        //            List<MetricInfo> workerMetrics = client.getClient().getMetrics(id, MetaType.WORKER.getT());
        //            System.out.println("workerMetrics:" + workerMetrics);
        List<UIWorkerMetric> workerData = UIMetricUtils.getWorkerMetrics(workerMetrics, id, window);
        model.addAttribute("workerData", workerData);
        model.addAttribute("workerHead", UIMetricUtils.sortHead(workerData, UIWorkerMetric.HEAD));
        List<TaskEntity> taskData = UIUtils.getTaskEntities(topologyInfo);
        model.addAttribute("taskData", taskData);
    } catch (NotAliveException nae) {
        model.addAttribute("flush", String.format("The topology: %s is dead.", id));
    } catch (Exception e) {
        NimbusClientManager.removeClient(cluster);
        LOG.error(e.getMessage(), e);
        UIUtils.addErrorAttribute(model, e);
    }
    model.addAttribute("page", "topology");
    model.addAttribute("clusterName", cluster);
    UIUtils.addTitleAttribute(model, "Topology Summary");
    LOG.info("topology page show cost:{}ms", System.currentTimeMillis() - start);
    return "topology";
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class NimbusClientManager method getNimbusClient.

public static NimbusClient getNimbusClient(String clusterName) throws Exception {
    Map conf = UIUtils.readUiConfig();
    NimbusClient client = clientManager.get(clusterName);
    if (client != null) {
        try {
            client.getClient().getVersion();
            LOG.info("get Nimbus Client from clientManager");
        } catch (Exception e) {
            LOG.info("Nimbus has been restarted, it begin to reconnect");
            client = null;
        }
    }
    if (client == null) {
        conf = UIUtils.resetZKConfig(conf, clusterName);
        client = NimbusClient.getConfiguredClient(conf);
        clientManager.put(clusterName, client);
    }
    return client;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map) TimeCacheMap(com.alibaba.jstorm.utils.TimeCacheMap)

Example 20 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class UIUtils method getNimbusConf.

public static Map<String, Object> getNimbusConf(String clusterName) {
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        String jsonConf = client.getClient().getNimbusConf();
        Map<String, Object> nimbusConf = (Map<String, Object>) Utils.from_json(jsonConf);
        return nimbusConf;
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        LOG.error(e.getMessage(), e);
        return UIUtils.readUiConfig();
    }
}
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