当前位置: 首页>>代码示例>>Java>>正文


Java WorkerSummary类代码示例

本文整理汇总了Java中backtype.storm.generated.WorkerSummary的典型用法代码示例。如果您正苦于以下问题:Java WorkerSummary类的具体用法?Java WorkerSummary怎么用?Java WorkerSummary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

WorkerSummary类属于backtype.storm.generated包,在下文中一共展示了WorkerSummary类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: mkWorkerSummary

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
public static List<WorkerSummary> mkWorkerSummary(String topology,
		Assignment assignment, Map<Integer, TaskSummary> taskSumm) {
	Set<ResourceWorkerSlot> workers = assignment.getWorkers();
	List<WorkerSummary> result = new ArrayList<WorkerSummary>();
	for (ResourceWorkerSlot worker : workers) {
		WorkerSummary workerSumm = new WorkerSummary();
		workerSumm.set_topology(topology);
		workerSumm.set_port(worker.getPort());
		List<TaskSummary> tasks = new ArrayList<TaskSummary>();
		workerSumm.set_tasks(tasks);
		for (Integer taskId : worker.getTasks()) {
			TaskSummary task = taskSumm.get(taskId);
			if (task == null)
				continue;
			tasks.add(task);
		}
		result.add(workerSumm);
	}
	return result;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:21,代码来源:NimbusUtils.java


示例2: mkWorkerSummary

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
public static List<WorkerSummary> mkWorkerSummary(String topology, Assignment assignment,
                                                  Map<Integer, TaskSummary> taskSumm) {
    Set<ResourceWorkerSlot> workers = assignment.getWorkers();
    List<WorkerSummary> result = new ArrayList<WorkerSummary>();
    for (ResourceWorkerSlot worker : workers) {
        WorkerSummary workerSumm = new WorkerSummary();
        workerSumm.set_topology(topology);
        workerSumm.set_port(worker.getPort());
        List<TaskSummary> tasks = new ArrayList<TaskSummary>();
        workerSumm.set_tasks(tasks);
        for (Integer taskId : worker.getTasks()) {
            TaskSummary task = taskSumm.get(taskId);
            if (task == null)
                continue;
            tasks.add(task);
        }
        result.add(workerSumm);
    }
    return result;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:21,代码来源:NimbusUtils.java


示例3: generateWorkerSum

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
private void generateWorkerSum(List<WorkerSummary> workerSummaries) {
	wsumm = new ArrayList<WorkerSumm>();

	for (WorkerSummary workerSummary : workerSummaries) {
		wsumm.add(new WorkerSumm(workerSummary));
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:8,代码来源:SupervisorPage.java


示例4: WorkerSumm

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
public WorkerSumm(WorkerSummary workerSummary) {
	this.port = String.valueOf(workerSummary.get_port());
	this.topology = workerSummary.get_topology();

	StringBuilder taskSB = new StringBuilder();
	StringBuilder componentSB = new StringBuilder();
	boolean isFirst = true;

	int minUptime = 0;
	taskSummList = workerSummary.get_tasks();
	for (TaskSummary taskSummary : taskSummList) {
		if (isFirst == false) {
			taskSB.append(',');
			componentSB.append(',');
		} else {
			minUptime = taskSummary.get_uptime_secs();
		}

		taskSB.append(taskSummary.get_task_id());
		componentSB.append(taskSummary.get_component_id());

		if (minUptime < taskSummary.get_uptime_secs()) {
			minUptime = taskSummary.get_uptime_secs();
		}

		isFirst = false;
	}

	this.uptime = StatBuckets.prettyUptimeStr(minUptime);
	this.tasks = taskSB.toString();
	this.components = componentSB.toString();

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:34,代码来源:WorkerSumm.java


示例5: topologySummary

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
/**
 * Convert thrift TopologyInfo to UI bean TopologySumm
 * 
 * @param summ
 * @return
 */
public static List<TopologySumm> topologySummary(TopologyInfo t) {

	List<WorkerSummary> workers = t.get_workers();
	int taskNum = 0;
	int memNum = 0;
	for (WorkerSummary worker : workers) {
		taskNum += worker.get_tasks_size();
	}

	List<TopologySumm> tsumm = new ArrayList<TopologySumm>();

	// TopologySumm ts = new TopologySumm(summ.get_name(), summ.get_id(),
	// summ.get_status(), StatBuckets.prettyUptimeStr(summ
	// .get_uptime_secs()), String.valueOf(workers.size()),
	// String.valueOf(taskSize), summ.get_uptime_secs());

	TopologySumm topologySumm = new TopologySumm();
	topologySumm.setTopologyId(t.get_id());
	topologySumm.setTopologyName(t.get_name());
	topologySumm.setStatus(t.get_status());
	topologySumm
			.setUptime(StatBuckets.prettyUptimeStr(t.get_uptime_secs()));

	topologySumm.setNumWorkers(String.valueOf(workers.size()));
	topologySumm.setNumTasks(String.valueOf(taskNum));

	tsumm.add(topologySumm);
	return tsumm;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:36,代码来源:UIUtils.java


示例6: getWorkerMetrics

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
private List<UIWorkerMetric> getWorkerMetrics(Map<String, MetricInfo> workerMetricInfo,
                                            List<WorkerSummary> workerSummaries, String host, int window) {
    Map<String, UIWorkerMetric> workerMetrics = new HashMap<>();
    for (MetricInfo info : workerMetricInfo.values()) {
        if (info != null) {
            for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
                String name = metric.getKey();
                String[] split_name = name.split("@");
                String _host = UIMetricUtils.extractComponentName(split_name);
                if (!host.equals(_host)) continue;

                //only handle the specific host
                String port = UIMetricUtils.extractTaskId(split_name);
                String key = host + ":" + port;
                String metricName = UIMetricUtils.extractMetricName(split_name);
                MetricSnapshot snapshot = metric.getValue().get(window);

                UIWorkerMetric workerMetric;
                if (workerMetrics.containsKey(key)) {
                    workerMetric = workerMetrics.get(key);
                } else {
                    workerMetric = new UIWorkerMetric(host, port);
                    workerMetrics.put(key, workerMetric);
                }
                workerMetric.setMetricValue(snapshot, metricName);
            }
        }
    }

    for (WorkerSummary ws : workerSummaries){
        String worker = host + ":" + ws.get_port();
        if (workerMetrics.containsKey(worker)) {
            workerMetrics.get(worker).setTopology(ws.get_topology());
        }
    }

    return new ArrayList<>(workerMetrics.values());
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:39,代码来源:SupervisorController.java


示例7: getWorkerMetrics

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
public static List<UIWorkerMetric> getWorkerMetrics(Map<String, MetricInfo> workerMetricInfo,
                                              List<WorkerSummary> workerSummaries, String host, int window) {
    Map<String, UIWorkerMetric> workerMetrics = new HashMap<>();
    for (MetricInfo info : workerMetricInfo.values()) {
        if (info != null) {
            for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
                String name = metric.getKey();
                String[] split_name = name.split("@");
                String _host = UIMetricUtils.extractComponentName(split_name);
                if (!host.equals(_host)) continue;

                //only handle the specific host
                String port = UIMetricUtils.extractTaskId(split_name);
                String key = host + ":" + port;
                String metricName = UIMetricUtils.extractMetricName(split_name);
                MetricSnapshot snapshot = metric.getValue().get(window);

                UIWorkerMetric workerMetric;
                if (workerMetrics.containsKey(key)) {
                    workerMetric = workerMetrics.get(key);
                } else {
                    workerMetric = new UIWorkerMetric(host, port);
                    workerMetrics.put(key, workerMetric);
                }
                workerMetric.setMetricValue(snapshot, metricName);
            }
        }
    }

    for (WorkerSummary ws : workerSummaries){
        String worker = host + ":" + ws.get_port();
        if (workerMetrics.containsKey(worker)) {
            workerMetrics.get(worker).setTopology(ws.get_topology());
        }
    }

    return new ArrayList<>(workerMetrics.values());
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:39,代码来源:UIMetricUtils.java


示例8: WorkerEntity

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
public WorkerEntity(WorkerSummary worker){
    this.topology = worker.get_topology();
    this.port = worker.get_port();
    this.uptimeSeconds = worker.get_uptime();
    this.uptime = UIUtils.prettyUptime(uptimeSeconds);
    tasks = new ArrayList<>();
    for (TaskComponent task : worker.get_tasks()){
        Map<String, Object> t = new HashMap<>();
        t.put("id", task.get_taskId());
        t.put("component", task.get_component());
        tasks.add(t);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:14,代码来源:WorkerEntity.java


示例9: getTopologyInfo

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
/**
 * Get TopologyInfo, it contain all data of the topology running status
 * 
 * @return TopologyInfo
 */
public TopologyInfo getTopologyInfo(String topologyId, StormBase base)
		throws Exception {
	
	StormClusterState stormClusterState = data.getStormClusterState();

	TopologyInfo topologyInfo = new TopologyInfo();
	
	topologyInfo.set_id(topologyId);
	topologyInfo.set_name(base.getStormName());
	topologyInfo.set_uptime_secs(TimeUtils.time_delta(base
			.getLanchTimeSecs()));
	topologyInfo.set_status(base.getStatusString());

	// get topology's Assignment
	Assignment assignment = stormClusterState.assignment_info(
			topologyId, null);
	if (assignment == null) {
		throw new TException("Failed to get StormBase from ZK of "
				+ topologyId);
	}

	// get topology's map<taskId, componentId>
	Map<Integer, String> taskInfo = Cluster.topology_task_info(
			stormClusterState, topologyId);

	Map<Integer, TaskSummary> tasks = NimbusUtils.mkTaskSummary(
			stormClusterState, assignment, taskInfo, topologyId);
	List<TaskSummary> taskSumms = new ArrayList<TaskSummary>();
	for (Entry<Integer, TaskSummary> entry : tasks.entrySet()) {
		taskSumms.add(entry.getValue());
	}
	topologyInfo.set_tasks(taskSumms);
	List<WorkerSummary> workers = NimbusUtils.mkWorkerSummary(
			topologyId, assignment, tasks);
	topologyInfo.set_workers(workers);

	// get user defined metrics data
	List<UserDefMetric> udm = new ArrayList<UserDefMetric>();
	udm = getUserDefMetrics(topologyId);
	topologyInfo.set_userDefMetric(udm);
	
	return topologyInfo;

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:50,代码来源:ServiceHandler.java


示例10: show

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
@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) {
        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", JStormUtils.thriftToMap(supervisorWorkers.get_supervisor()));

            //get worker summary
            List<WorkerSummary> workerSummaries = supervisorWorkers.get_workers();
            model.addAttribute("workerSummary", JStormUtils.thriftToMap(workerSummaries));

            //get worker metrics
            Map<String, MetricInfo> workerMetricInfo = supervisorWorkers.get_workerMetric();
            List<UIWorkerMetric> workerMetrics = 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";
    }
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:45,代码来源:SupervisorController.java


示例11: show

import backtype.storm.generated.WorkerSummary; //导入依赖的package包/类
@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) {
        if (UIUtils.isValidSupervisorHost(clusterName, host)) {
            UIUtils.addErrorAttribute(model, new RuntimeException("Not a valid host: " + host));
            return "supervisor";
        }

        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";
    }
 
开发者ID:alibaba,项目名称:jstorm,代码行数:52,代码来源:SupervisorController.java



注:本文中的backtype.storm.generated.WorkerSummary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。