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


Java NimbusClient类代码示例

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


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

示例1: topologyNameExists

import backtype.storm.utils.NimbusClient; //导入依赖的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: summaryMetrics

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
@RequestMapping("/summary/metrics")
public List<ChartSeries> summaryMetrics(@PathVariable String clusterName,
                                        @RequestParam(value = "win", required = false) String win) {
    int window = UIUtils.parseWindow(win);
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        List<MetricInfo> infos = client.getClient().getMetrics(JStormMetrics.CLUSTER_METRIC_KEY,
                MetaType.TOPOLOGY.getT());
        return UIUtils.getChartSeries(infos, window);
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        LOG.error(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:17,代码来源:ClusterAPIController.java

示例3: getNimbusClient

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
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;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:22,代码来源:NimbusClientManager.java

示例4: registerMetrics

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
private Map<String, Long> registerMetrics(Set<String> names) {
    if (test || !enableMetrics) {
        return new HashMap<>();
    }
    try {
        if (client == null) {
            client = NimbusClient.getConfiguredClient(conf);
        }

        return client.getClient().registerMetrics(topologyId, names);
    } catch (Exception e) {
        LOG.error("Failed to gen metric ids", e);
        if (client != null) {
            client.close();
            client = NimbusClient.getConfiguredClient(conf);
        }
    }

    return null;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:21,代码来源:JStormMetricsReporter.java

示例5: setTaskHeatbeat

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
private void setTaskHeatbeat(TopologyTaskHbInfo topologyTaskHbInfo) {
    try {
        if (topologyTaskHbInfo == null) {
            return;
        }
        if (topologyTaskHbInfo.get_taskHbs() == null) {
            return;
        }

        client.getClient().updateTaskHeartbeat(topologyTaskHbInfo);

        String info = "";
        for (Entry<Integer, TaskHeartbeat> entry : topologyTaskHbInfo.get_taskHbs().entrySet()) {
            info += " " + entry.getKey() + "-" + entry.getValue().get_time(); 
        }
        LOG.info("Update task heartbeat:" + info);
    } catch (TException e) {
        LOG.error("Failed to update task heartbeat info", e);
        if (client != null) {
            client.close();
            client = NimbusClient.getConfiguredClient(conf);
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:25,代码来源:TaskHeartbeatUpdater.java

示例6: submitRebalance

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
public static void submitRebalance(String topologyName, RebalanceOptions options, Map conf) throws Exception {
    Map stormConf = Utils.readStormConfig();
    if (conf != null) {
        stormConf.putAll(conf);
    }

    NimbusClient client = null;
    try {
        client = NimbusClient.getConfiguredClient(stormConf);
        client.getClient().rebalance(topologyName, options);
    } catch (Exception e) {
        throw e;
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:19,代码来源:rebalance.java

示例7: getTopologyDetails

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
/**
 * Get all running topology's details.
 *
 * @param conf storm's conf, used to connect nimbus
 * @return null if nimbus is not available, otherwise all TopologyDetails
 */
public static Topologies getTopologyDetails(Map<String, Object> conf) {
    NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
    try {
        Nimbus.Client nimbus = nimbusClient.getClient();
        Map<String, TopologyDetails> topologies = nimbus.getClusterInfo().get_topologies().stream()
                .map(topoSummary -> getTopologyDetails(nimbus, topoSummary))
                .filter(Objects::nonNull)
                .collect(Collectors.toMap(topoDetails -> topoDetails.getId(), topoDetails -> topoDetails));
        return new Topologies(topologies);
    } catch (TException e) {
    } finally {
        nimbusClient.close();
    }
    return null;
}
 
开发者ID:ADSC-Resa,项目名称:resa,代码行数:22,代码来源:TopologyHelper.java

示例8: topologyNameExists

import backtype.storm.utils.NimbusClient; //导入依赖的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

示例9: submitJar

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
public static String submitJar(Map conf, String localJar) {
    if(localJar==null) {
        throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
    }
    NimbusClient client = NimbusClient.getConfiguredClient(conf);
    try {
        String uploadLocation = client.getClient().beginFileUpload();
        LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
        BufferFileInputStream is = new BufferFileInputStream(localJar, THRIFT_CHUNK_SIZE_BYTES);
        while(true) {
            byte[] toSubmit = is.read();
            if(toSubmit.length==0) break;
            client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
        }
        client.getClient().finishFileUpload(uploadLocation);
        LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
        return uploadLocation;
    } catch(Exception e) {
        throw new RuntimeException(e);            
    } finally {
        client.close();
    }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:24,代码来源:StormSubmitter.java

示例10: submitJar

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
public static String submitJar(Map conf, String localJar) {
    if(localJar==null) {
        throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
    }
    NimbusClient client = NimbusClient.getConfiguredClient(conf);
    try {
        String uploadLocation = client.getClient().beginFileUpload();
        LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
        BufferFileInputStream is = new BufferFileInputStream(localJar);
        while(true) {
            byte[] toSubmit = is.read();
            if(toSubmit.length==0) break;
            client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
        }
        client.getClient().finishFileUpload(uploadLocation);
        LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
        return uploadLocation;
    } catch(Exception e) {
        throw new RuntimeException(e);            
    } finally {
        client.close();
    }
}
 
开发者ID:troyding,项目名称:storm-resa,代码行数:24,代码来源:StormSubmitter.java

示例11: cleanCluster

import backtype.storm.utils.NimbusClient; //导入依赖的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

示例12: supervisors

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
@RequestMapping("/supervisor/summary")
public Map supervisors(@PathVariable String clusterName){
    Map ret;
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
        ret = new HashMap<>();
        ret.put("supervisors", UIUtils.getSupervisorEntities(clusterSummary));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        ret = UIUtils.exceptionJson(e);
        LOG.error(e.getMessage(), e);
    }
    return ret;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:17,代码来源:ClusterAPIController.java

示例13: nimbus

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
@RequestMapping("/nimbus/summary")
public Map nimbus(@PathVariable String clusterName){
    Map ret;
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
        ret = new HashMap<>();
        ret.put("nimbus", UIUtils.getNimbusEntities(clusterSummary));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        ret = UIUtils.exceptionJson(e);
        LOG.error(e.getMessage(), e);
    }
    return ret;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:17,代码来源:ClusterAPIController.java

示例14: topology

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
@RequestMapping("/topology/summary")
public Map topology(@PathVariable String clusterName){
    Map ret = new HashMap<>();
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
        List<TopologyEntity> topologies = UIUtils.getTopologyEntities(clusterSummary);
        ret.put("topologies", topologies);
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        ret = UIUtils.exceptionJson(e);
        LOG.error(e.getMessage(), e);
    }
    return ret;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:17,代码来源:ClusterAPIController.java

示例15: summaryMetrics

import backtype.storm.utils.NimbusClient; //导入依赖的package包/类
@RequestMapping("/metrics")
public Map summaryMetrics(@PathVariable String clusterName, @PathVariable String topology) {
    int window = 60;    //we only get the 60s window
    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;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:18,代码来源:TopologyAPIController.java


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