本文整理汇总了Java中backtype.storm.utils.NimbusClient.getClient方法的典型用法代码示例。如果您正苦于以下问题:Java NimbusClient.getClient方法的具体用法?Java NimbusClient.getClient怎么用?Java NimbusClient.getClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.NimbusClient
的用法示例。
在下文中一共展示了NimbusClient.getClient方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: getSlots
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
private List<String> getSlots() throws Exception {
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
Nimbus.Client nimbus = nimbusClient.getClient();
List<String> slots = nimbus.getClusterInfo().get_supervisors().stream()
.flatMap(s -> Arrays.asList(s.get_host() + ":6700", s.get_host() + ":6701").stream())
.collect(Collectors.toList());
Collections.shuffle(slots);
System.out.println(slots.size());
return slots;
}
示例3: doRebalance
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
private void doRebalance(String topoName, int numWorkers) throws Exception {
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
Nimbus.Client nimbus = nimbusClient.getClient();
RebalanceOptions options = new RebalanceOptions();
options.set_num_workers(numWorkers);
options.set_wait_secs(1);
System.out.println("Reassigning to " + numWorkers + " workers");
nimbus.rebalance(topoName, options);
}
示例4: killTopology
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
/**
* Kill a specified topology.
*
* @param topoName
* @param conf
*/
public static void killTopology(String topoName, Map<String, Object> conf) {
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
try {
Nimbus.Client nimbus = nimbusClient.getClient();
nimbus.killTopology(topoName);
} catch (NotAliveException | TException e) {
} finally {
nimbusClient.close();
}
}
示例5: getTopologyExecutors
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
public static Map<String, List<ExecutorDetails>> getTopologyExecutors(String topoName, Map<String, Object> conf) {
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
try {
Nimbus.Client nimbus = nimbusClient.getClient();
String topoId = getTopologyId(nimbus, topoName);
return getTopologyExecutors(nimbus, topoId);
} catch (Exception e) {
} finally {
nimbusClient.close();
}
return null;
}
示例6: getTopologyId
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
public static String getTopologyId(String topoName, Map<String, Object> conf) {
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
try {
Nimbus.Client nimbus = nimbusClient.getClient();
return getTopologyId(nimbus, topoName);
} finally {
nimbusClient.close();
}
}
示例7: getGeneralTopologyContext
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
public static GeneralTopologyContext getGeneralTopologyContext(String topoName, Map<String, Object> conf) {
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
try {
Nimbus.Client nimbus = nimbusClient.getClient();
return getGeneralTopologyContext(nimbus, topoName);
} finally {
nimbusClient.close();
}
}
示例8: uploadMetrics
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
/**
* upload metrics sequentially due to thrift frame size limit (15MB)
*/
private void uploadMetrics(TopologyMetric tpMetric) {
long start = System.currentTimeMillis();
if (StormConfig.local_mode(conf)) {
return;
} else {
NimbusClient client = null;
try {
client = NimbusClient.getConfiguredClient(conf);
Nimbus.Client client1 = client.getClient();
MetricInfo topologyMetrics = tpMetric.get_topologyMetric();
MetricInfo componentMetrics = tpMetric.get_componentMetric();
MetricInfo taskMetrics = tpMetric.get_taskMetric();
MetricInfo streamMetrics = tpMetric.get_streamMetric();
MetricInfo workerMetrics = tpMetric.get_workerMetric();
MetricInfo nettyMetrics = tpMetric.get_nettyMetric();
int totalSize = topologyMetrics.get_metrics_size() + componentMetrics.get_metrics_size() +
taskMetrics.get_metrics_size() + streamMetrics.get_metrics_size() +
workerMetrics.get_metrics_size() + nettyMetrics.get_metrics_size();
// for small topologies, send all metrics together to ease the pressure of nimbus
if (totalSize < MAX_BATCH_SIZE) {
client1.uploadTopologyMetrics(topologyId,
new TopologyMetric(topologyMetrics, componentMetrics, workerMetrics, taskMetrics,
streamMetrics, nettyMetrics));
} else {
client1.uploadTopologyMetrics(topologyId,
new TopologyMetric(topologyMetrics, componentMetrics, dummy, dummy, dummy, dummy));
batchUploadMetrics(client1, topologyId, workerMetrics, MetaType.WORKER);
batchUploadMetrics(client1, topologyId, taskMetrics, MetaType.TASK);
batchUploadMetrics(client1, topologyId, streamMetrics, MetaType.STREAM);
batchUploadMetrics(client1, topologyId, nettyMetrics, MetaType.NETTY);
}
} catch (Exception e) {
LOG.error("Failed to upload worker metrics", e);
} finally {
if (client != null) {
client.close();
}
}
}
metricLogger.info("upload metrics, cost:{}", System.currentTimeMillis() - start);
}
示例9: testRebalanceUsingTopologyHelper
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
@Test
public void testRebalanceUsingTopologyHelper() throws Exception {
conf.put(Config.NIMBUS_HOST, "192.168.0.31");
conf.put(Config.NIMBUS_THRIFT_PORT, 6627);
conf.put("resa.opt.smd.qos.ms", 1500.0);
conf.put("resa.opt.win.history.size", 3);
GeneralTopologyContext gtc = TopologyHelper.getGeneralTopologyContext("ta1wc", conf);
if (gtc == null) {
System.out.println("gtc is null");
return;
}
String host = "192.168.0.31";
int port = 6379;
String queue = "ta1wc";
int maxLen = 500;
String topoName = "ta1wc";
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
Nimbus.Client nimbus = nimbusClient.getClient();
String topoId = TopologyHelper.getTopologyId(nimbus, topoName);
Map<String, List<ExecutorDetails>> comp2Executors = TopologyHelper.getTopologyExecutors(topoName, conf)
.entrySet().stream().filter(e -> !Utils.isSystemId(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
for (int i = 0; i < 10000; i++) {
Utils.sleep(10000);
TopologyInfo topoInfo = nimbus.getTopologyInfo(topoId);
Map<String, Integer> currAllocation = topoInfo.get_executors().stream().filter(e -> !Utils.isSystemId(e.get_component_id()))
.collect(Collectors.groupingBy(e -> e.get_component_id(),
Collectors.reducing(0, e -> 1, (i1, i2) -> i1 + i2)));
System.out.println("-------------Report on: " + System.currentTimeMillis() + "------------------------------");
System.out.println(currAllocation);
}
}
示例10: testMakeUsingTopologyHelper
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
@Test
public void testMakeUsingTopologyHelper() throws Exception {
conf.put(Config.NIMBUS_HOST, "192.168.0.30");
conf.put(Config.NIMBUS_THRIFT_PORT, 6627);
conf.put("resa.opt.smd.qos.ms", 1500.0);
conf.put("resa.opt.win.history.size", 3);
conf.put("resa.comp.sample.rate", 1.0);
conf.put(ResaConfig.ALLOWED_EXECUTOR_NUM, 7);
GeneralTopologyContext gtc = TopologyHelper.getGeneralTopologyContext("ta1wc2Redis", conf);
if (gtc == null) {
System.out.println("gtc is null");
return;
}
String host = "192.168.0.30";
int port = 6379;
String queue = "ta1wc";
int maxLen = 500;
String topoName = "ta1wc2Redis";
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
Nimbus.Client nimbus = nimbusClient.getClient();
String topoId = TopologyHelper.getTopologyId(nimbus, topoName);
TopologyInfo topoInfo = nimbus.getTopologyInfo(topoId);
Map<String, Integer> currAllocation = topoInfo.get_executors().stream().filter(e -> !Utils.isSystemId(e.get_component_id()))
.collect(Collectors.groupingBy(e -> e.get_component_id(),
Collectors.reducing(0, e -> 1, (i1, i2) -> i1 + i2)));
SimpleGeneralAllocCalculator smdm = new SimpleGeneralAllocCalculator();
smdm.init(conf, currAllocation, gtc.getRawTopology());
Map<String, List<ExecutorDetails>> comp2Executors = TopologyHelper.getTopologyExecutors(topoName, conf)
.entrySet().stream().filter(e -> !Utils.isSystemId(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
for (int i = 0; i < 10000; i++) {
Utils.sleep(30000);
topoInfo = nimbus.getTopologyInfo(topoId);
Map<String, Integer> updatedAllocation = topoInfo.get_executors().stream().filter(e -> !Utils.isSystemId(e.get_component_id()))
.collect(Collectors.groupingBy(e -> e.get_component_id(),
Collectors.reducing(0, e -> 1, (i1, i2) -> i1 + i2)));
AggResultCalculator resultCalculator = new AggResultCalculator(
RedisDataSource.readData(host, port, queue, maxLen), comp2Executors, gtc.getRawTopology());
resultCalculator.calCMVStat();
System.out.println("-------------Report on: " + System.currentTimeMillis() + "------------------------------");
if (currAllocation.equals(updatedAllocation)) {
System.out.println(currAllocation + "-->" + smdm.calc(resultCalculator.getResults(), 7));
} else {
currAllocation = updatedAllocation;
smdm.allocationChanged(currAllocation);
System.out.println("Allocation updated to " + currAllocation);
}
}
}
示例11: testMakeUsingTopologyHelperForkTopology
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
@Test
public void testMakeUsingTopologyHelperForkTopology() throws Exception {
conf.put(Config.NIMBUS_HOST, "192.168.0.30");
conf.put(Config.NIMBUS_THRIFT_PORT, 6627);
conf.put("resa.opt.smd.qos.ms", 1500.0);
conf.put("resa.opt.win.history.size", 3);
conf.put("resa.opt.win.history.size.ignore", -1);
conf.put("resa.comp.sample.rate", 1.0);
int allewedExecutorNum = 24;
conf.put(ResaConfig.ALLOWED_EXECUTOR_NUM, allewedExecutorNum);
String host = "192.168.0.30";
int port = 6379;
String queue = "ta1wc";
int maxLen = 5000;
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
Nimbus.Client nimbus = nimbusClient.getClient();
//String topoName = "ta1wc2P2Redis";
///String topoName = "ta1wcLoopRedis";
///String topoName = "arwcRedis";
///String topoName = "outdetResa";
///String topoName = "rwc";
String topoName = "fpt";
String topoId = TopologyHelper.getTopologyId(nimbus, topoName);
TopologyInfo topoInfo = nimbus.getTopologyInfo(topoId);
Map<String, Integer> currAllocation = topoInfo.get_executors().stream().filter(e -> !Utils.isSystemId(e.get_component_id()))
.collect(Collectors.groupingBy(e -> e.get_component_id(),
Collectors.reducing(0, e -> 1, (i1, i2) -> i1 + i2)));
SimpleGeneralAllocCalculator smdm = new SimpleGeneralAllocCalculator();
smdm.init(conf, currAllocation, nimbus.getUserTopology(topoId));
for (int i = 0; i < 10000; i++) {
Utils.sleep(30000);
topoInfo = nimbus.getTopologyInfo(topoId);
Map<String, Integer> updatedAllocation = topoInfo.get_executors().stream().filter(e -> !Utils.isSystemId(e.get_component_id()))
.collect(Collectors.groupingBy(e -> e.get_component_id(),
Collectors.reducing(0, e -> 1, (i1, i2) -> i1 + i2)));
Map<String, List<ExecutorDetails>> comp2Executors = TopologyHelper.getTopologyExecutors(topoName, conf)
.entrySet().stream().filter(e -> !Utils.isSystemId(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
AggResultCalculator resultCalculator = new AggResultCalculator(
RedisDataSource.readData(host, port, queue, maxLen), comp2Executors, nimbus.getUserTopology(topoId));
resultCalculator.calCMVStat();
System.out.println("-------------Report on: " + System.currentTimeMillis() + "------------------------------");
if (currAllocation.equals(updatedAllocation)) {
System.out.println(currAllocation + "-->" + smdm.calc(resultCalculator.getResults(), allewedExecutorNum));
} else {
currAllocation = updatedAllocation;
smdm.allocationChanged(currAllocation);
RedisDataSource.clearQueue(host, port, queue);
System.out.println("Allocation updated to " + currAllocation);
}
}
}
示例12: runAllocCalculatorAlg
import backtype.storm.utils.NimbusClient; //导入方法依赖的package包/类
@Test
public void runAllocCalculatorAlg() throws Exception {
conf.put(Config.NIMBUS_HOST, "192.168.0.30");
conf.put(Config.NIMBUS_THRIFT_PORT, 6627);
conf.put("resa.opt.smd.qos.ms", 1500.0);
conf.put("resa.opt.win.history.size", 1);
conf.put("resa.opt.win.history.size.ignore", 0);
conf.put("resa.comp.sample.rate", 1.0);
int allewedExecutorNum = 24;
conf.put(ResaConfig.ALLOWED_EXECUTOR_NUM, allewedExecutorNum);
String host = "192.168.0.30";
int port = 6379;
String queue = "fpm-7-1417774110-metrics";
int maxLen = 5000;
NimbusClient nimbusClient = NimbusClient.getConfiguredClient(conf);
Nimbus.Client nimbus = nimbusClient.getClient();
//String topoName = "ta1wc2P2Redis";
///String topoName = "ta1wcLoopRedis";
///String topoName = "arwcRedis";
///String topoName = "outdetResa";
///String topoName = "rwc";
String topoName = "fpm";
String topoId = TopologyHelper.getTopologyId(nimbus, topoName);
TopologyInfo topoInfo = nimbus.getTopologyInfo(topoId);
Map<String, Integer> currAllocation = topoInfo.get_executors().stream().filter(e -> !Utils.isSystemId(e.get_component_id()))
.collect(Collectors.groupingBy(e -> e.get_component_id(),
Collectors.reducing(0, e -> 1, (i1, i2) -> i1 + i2)));
SimpleGeneralAllocCalculator smdm = new SimpleGeneralAllocCalculator();
smdm.init(conf, currAllocation, nimbus.getUserTopology(topoId));
Map<String, List<ExecutorDetails>> comp2Executors = TopologyHelper.getTopologyExecutors(topoName, conf)
.entrySet().stream().filter(e -> !Utils.isSystemId(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
AggResultCalculator resultCalculator = new AggResultCalculator(
RedisDataSource.iterData(host, port, queue, maxLen), comp2Executors, nimbus.getUserTopology(topoId));
resultCalculator.calCMVStat();
System.out.println("-------------Report on: " + System.currentTimeMillis() + "------------------------------");
System.out.println(currAllocation + "-->" + smdm.calc(resultCalculator.getResults(), allewedExecutorNum).currOptAllocation);
}