本文整理汇总了Java中backtype.storm.utils.NimbusClient.close方法的典型用法代码示例。如果您正苦于以下问题:Java NimbusClient.close方法的具体用法?Java NimbusClient.close怎么用?Java NimbusClient.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.NimbusClient
的用法示例。
在下文中一共展示了NimbusClient.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: 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;
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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);
}
}
示例7: main
import backtype.storm.utils.NimbusClient; //导入方法依赖的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();
}
}
}
示例8: rollbackTopology
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
private static void rollbackTopology(String topologyName) {
Map conf = Utils.readStormConfig();
NimbusClient client = NimbusClient.getConfiguredClient(conf);
try {
// update jar
client.getClient().rollbackTopology(topologyName);
CommandLineUtil.success("Successfully submit command rollback_topology " + topologyName);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
示例9: main
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
public static void main(String[] args) {
if (args == null || args.length == 0) {
throw new InvalidParameterException("Please input topology name");
}
String topologyName = args[0];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
client.getClient().deactivate(topologyName);
System.out.println("Successfully submit command deactivate " + topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
示例10: completeTopology
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
private static void completeTopology(String topologyName)
throws Exception {
Map conf = Utils.readStormConfig();
NimbusClient client = NimbusClient.getConfiguredClient(conf);
try {
client.getClient().completeUpgrade(topologyName);
CommandLineUtil.success("Successfully submit command complete_upgrade " + topologyName);
} catch (Exception ex) {
CommandLineUtil.error("Failed to perform complete_upgrade: " + ex.getMessage());
ex.printStackTrace();
} finally {
if (client != null) {
client.close();
}
}
}
示例11: main
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
public static void main(String[] args) {
if (args == null || args.length == 0) {
throw new InvalidParameterException("Please input topology name");
}
String topologyName = args[0];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
client.getClient().activate(topologyName);
System.out.println("Successfully submit command activate " + topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
示例12: init
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void init(String host) throws Exception {
NimbusClient client = null;
try {
Map conf = UIUtils.readUiConfig();
client = UIUtils.getNimbusClient(conf, clusterName);
SupervisorWorkers supervisorWorkers = client.getClient()
.getSupervisorWorkers(host);
ssumm = new ArrayList<SupervisorSumm>();
SupervisorSumm supervSumm = new SupervisorSumm(supervisorWorkers.get_supervisor());
ssumm.add(supervSumm);
ip = supervSumm.getIp();
generateWorkerSum(supervisorWorkers.get_workers());
getTopoList();
getTopoMetrList(client);
getWorkerMetrData();
} catch (Exception e) {
LOG.error("Failed to get cluster information:", e);
throw e;
} finally {
if (client != null) {
client.close();
}
}
}
示例13: main
import backtype.storm.utils.NimbusClient; //导入方法依赖的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();
}
}
}
示例14: main
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
/**
* @param args
*/
@SuppressWarnings("rawtypes")
public static void main(String[] args) {
if (args == null || args.length == 0) {
throw new InvalidParameterException("Should input topology name");
}
String topologyName = args[0];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
if (args.length == 1) {
client.getClient().rebalance(topologyName, null);
} else {
int delaySeconds = Integer.parseInt(args[1]);
RebalanceOptions options = new RebalanceOptions();
options.set_wait_secs(delaySeconds);
client.getClient().rebalance(topologyName, options);
}
System.out.println("Successfully submit command rebalance "
+ topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
示例15: main
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
/**
* @param args
*/
@SuppressWarnings("rawtypes")
public static void main(String[] args) {
if (args == null || args.length == 0) {
throw new InvalidParameterException("Should input topology name");
}
String topologyName = args[0];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
client.getClient().deactivate(topologyName);
System.out.println("Successfully submit command deactivate "
+ topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}