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


Java ClusterSummary类代码示例

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


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

示例1: topologyNameExists

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
private static boolean topologyNameExists(Map conf, String name) {
	NimbusClient client = NimbusClient.getConfiguredClient(conf);
	try {
		ClusterSummary summary = client.getClient().getClusterInfo();
		for (TopologySummary s : summary.get_topologies()) {
			if (s.get_name().equals(name)) {
				return true;
			}
		}
		return false;

	} catch (Exception e) {
		throw new RuntimeException(e);
	} finally {
		client.close();
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:18,代码来源:StormSubmitter.java

示例2: getComponents

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * @@@ Don't be compatible with Storm
 * 
 *     Here skip the logic
 * @param client
 * @param topology
 * @return
 * @throws Exception
 */
private HashSet<String> getComponents(Nimbus.Client client, String topology) throws Exception {
    HashSet<String> components = new HashSet<String>();
    ClusterSummary clusterSummary = client.getClusterInfo();
    TopologySummary topologySummary = null;
    for (TopologySummary ts : clusterSummary.get_topologies()) {
        if (topology.equals(ts.get_name())) {
            topologySummary = ts;
            break;
        }
    }
    if (topologySummary == null) {
        throw new IllegalArgumentException("topology: " + topology + " not found");
    } else {
        String id = topologySummary.get_id();
        // GetInfoOptions getInfoOpts = new GetInfoOptions();
        // getInfoOpts.set_num_err_choice(NumErrorsChoice.NONE);
        // TopologyInfo info = client.getTopologyInfoWithOpts(id, getInfoOpts);
        // for (ExecutorSummary es: info.get_executors()) {
        // components.add(es.get_component_id());
        // }
    }
    return components;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:33,代码来源:Monitor.java

示例3: getSupervisorHostIdMapping

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * Returns the mapping of supervisor host names to supervisor ids.
 * 
 * @param summary the cluster summary
 * @return the mapping (a host may run multiple supervisors and then we return them in the sequence given 
 *   by thrift)
 */
public static Map<String, List<String>> getSupervisorHostIdMapping(ClusterSummary summary) {
    Map<String, List<String>> result = new HashMap<String, List<String>>();
    List<SupervisorSummary> supervisors = summary.get_supervisors();
    for (int s = 0; s < summary.get_supervisors_size(); s++) {
        SupervisorSummary supervisor = supervisors.get(s);
        String host = supervisor.get_host();
        List<String> tmp = result.get(host);
        if (null == tmp) {
            tmp = new ArrayList<String>();
            result.put(host, tmp);
        }
        tmp.add(supervisor.get_supervisor_id());
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:23,代码来源:ThriftConnection.java

示例4: topologyNameExists

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
private static boolean topologyNameExists(Map conf, String name) {
    NimbusClient client = NimbusClient.getConfiguredClient(conf);
    try {
        ClusterSummary summary = client.getClient().getClusterInfo();
        for(TopologySummary s : summary.get_topologies()) {
            if(s.get_name().equals(name)) {  
                return true;
            } 
        }  
        return false;

    } catch(Exception e) {
        throw new RuntimeException(e);
    } finally {
        client.close();
    }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:18,代码来源:StormSubmitter.java

示例5: cleanCluster

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
public static void cleanCluster() {
    try {
        NimbusClient client = getNimbusClient(null);

        ClusterSummary clusterSummary = client.getClient().getClusterInfo();

        List<TopologySummary> topologySummaries = clusterSummary.get_topologies();

        KillOptions killOption = new KillOptions();
        killOption.set_wait_secs(1);
        for (TopologySummary topologySummary : topologySummaries) {
            client.getClient().killTopologyWithOpts(topologySummary.get_name(), killOption);
            LOG.info("Successfully kill " + topologySummary.get_name());
        }
    } catch (Exception e) {
        if (client != null) {
            client.close();
            client = null;

        }

        LOG.error("Failed to kill all topology ", e);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:25,代码来源:JStormHelper.java

示例6: main

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
public static void main(String[] args) {
    NimbusClient client = null;
    try {
        Map conf = Utils.readStormConfig();
        client = NimbusClient.getConfiguredClient(conf);

        if (args.length > 0 && !StringUtils.isBlank(args[0])) {
            String topologyName = args[0];
            TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName);
            System.out.println("Successfully get topology info \n" + Utils.toPrettyJsonString(info));
        } else {
            ClusterSummary clusterSummary = client.getClient().getClusterInfo();
            System.out.println("Successfully get cluster info \n" + Utils.toPrettyJsonString(clusterSummary));
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:25,代码来源:list.java

示例7: getClusterInfo

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
@Override
public ClusterSummary getClusterInfo() {
	
	try {
		return state.getNimbus().getClusterInfo();
	} catch (TException e) {
		
		LOG.error("fail to get cluster info", e);
	}
	return null;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:12,代码来源:LocalCluster.java

示例8: main

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * @param args
 */
@SuppressWarnings("rawtypes")
public static void main(String[] args) {

	NimbusClient client = null;
	try {

		Map conf = Utils.readStormConfig();
		client = NimbusClient.getConfiguredClient(conf);
		
		if (args.length > 0 && StringUtils.isBlank(args[0]) == false) {
			String topologyName = args[0];
			TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName);
			
			System.out.println("Successfully get topology info \n"
					+ Utils.toPrettyJsonString(info));
		}else {
			ClusterSummary clusterSummary = client.getClient().getClusterInfo();
			
			System.out.println("Successfully get cluster info \n"
					+ Utils.toPrettyJsonString(clusterSummary));
		}

		
	} catch (Exception e) {
		System.out.println(e.getMessage());
		e.printStackTrace();
		throw new RuntimeException(e);
	} finally {
		if (client != null) {
			client.close();
		}
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:37,代码来源:list.java

示例9: getClusterInfo

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
@Override
public ClusterSummary getClusterInfo() {
	// TODO Auto-generated method stub
	try {
		return state.getNimbus().getClusterInfo();
	} catch (TException e) {
		// TODO Auto-generated catch block
		LOG.error("fail to get cluster info", e);
	}
	return null;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:12,代码来源:LocalCluster.java

示例10: main

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {

	NimbusClient client = null;
	try {

		Map conf = Utils.readStormConfig();
		client = NimbusClient.getConfiguredClient(conf);
		
		if (args.length > 0 && StringUtils.isBlank(args[0]) == false) {
			String topologyName = args[0];
			TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName);
			
			System.out.println("Successfully get topology info \n"
					+ Utils.toPrettyJsonString(info));
		}else {
			ClusterSummary clusterSummary = client.getClient().getClusterInfo();
			
			System.out.println("Successfully get cluster info \n"
					+ Utils.toPrettyJsonString(clusterSummary));
		}

		
	} catch (Exception e) {
		System.out.println(e.getMessage());
		e.printStackTrace();
		throw new RuntimeException(e);
	} finally {
		if (client != null) {
			client.close();
		}
	}
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:36,代码来源:list.java

示例11: getClusterInfo

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
private void getClusterInfo(Client client) {
    try {
        ClusterSummary clusterSummary = client.getClusterInfo();
        List<SupervisorSummary> supervisorSummaryList = clusterSummary.get_supervisors();
        int totalWorkers = 0;
        int usedWorkers = 0;
        for(SupervisorSummary summary : supervisorSummaryList){
            totalWorkers += summary.get_num_workers() ;
            usedWorkers += summary.get_num_used_workers();
        }
        int freeWorkers = totalWorkers - usedWorkers;
        LOGGER.info("cluster totalWorkers = " + totalWorkers 
                + ", usedWorkers = " + usedWorkers 
                + ", freeWorkers  = " +  freeWorkers);
        
        HttpCatClient.sendMetric("ClusterMonitor", "freeSlots", "avg", String.valueOf(freeWorkers));
        HttpCatClient.sendMetric("ClusterMonitor", "totalSlots", "avg", String.valueOf(totalWorkers));
        
        List<TopologySummary> topologySummaryList = clusterSummary.get_topologies();
        long clusterTPS = 0l;
        for(TopologySummary topology : topologySummaryList){
            long topologyTPS = getTopologyTPS(topology, client);
            clusterTPS += topologyTPS;
            if(topology.get_name().startsWith("ClusterMonitor")){
                continue;
            }
            HttpCatClient.sendMetric(topology.get_name(), topology.get_name() + "-TPS", "avg", String.valueOf(topologyTPS));
        }
        HttpCatClient.sendMetric("ClusterMonitor", "ClusterEmitTPS", "avg", String.valueOf(clusterTPS));
        
    } catch (TException e) {
        initClient(configMap);
        LOGGER.error("get client info error.", e);
    }
    catch(NotAliveException nae){
        LOGGER.warn("topology is dead.", nae);
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:39,代码来源:ClusterInfoBolt.java

示例12: main

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {

    NimbusClient client = null;
    try {

        Map conf = Utils.readStormConfig();
        client = NimbusClient.getConfiguredClient(conf);

        if (args.length > 0 && StringUtils.isBlank(args[0]) == false) {
            String topologyName = args[0];
            TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName);

            System.out.println("Successfully get topology info \n" + Utils.toPrettyJsonString(info));
        } else {
            ClusterSummary clusterSummary = client.getClient().getClusterInfo();

            System.out.println("Successfully get cluster info \n" + Utils.toPrettyJsonString(clusterSummary));
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:33,代码来源:list.java

示例13: topologyExists

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * Returns whether a given topology exists within <code>summary</code>.
 * 
 * @param summary the summary object
 * @param topologyName the topology name
 * @return <code>true</code> if the topology exists, <code>false</code> else
 */
private static boolean topologyExists(ClusterSummary summary, String topologyName) {
    boolean result = false;
    for (TopologySummary s : summary.get_topologies()) {
        if (s.get_name().equals(topologyName)) {  
            result = true;
            break;
        } 
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:18,代码来源:StormUtils.java

示例14: getClusterInfo

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
@Override
public ClusterSummary getClusterInfo() throws TException {
    try {
        return cluster.getClusterInfo();
    } catch (Throwable e) {
        throw new TException(e.getMessage(), e.getCause());
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:9,代码来源:StormUtils.java

示例15: TopologySupport

import backtype.storm.generated.ClusterSummary; //导入依赖的package包/类
/**
 * Creates a topology supporting object.
 * 
 * @param topology the topology under consideration
 * @param thrift an open thrift connection
 * @param framework an open Curator connect to the zookeepers
 * @throws IOException in case that retrieving data fails
 */
private TopologySupport(TopologyInfo topology, ThriftConnection thrift, CuratorFramework framework) 
    throws IOException {
    this.topology = topology;
    this.framework = framework;
    try {
        ClusterSummary summary = thrift.getClusterSummary();
        this.hostIdMapping = ThriftConnection.getSupervisorHostIdMapping(summary);
        this.hostIdName = ThriftConnection.getSupervisorIdHostMapping(summary);
    } catch (TException e) {
        throw new IOException(e);
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:21,代码来源:StormUtils.java


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