本文整理汇总了Java中backtype.storm.generated.TopologyInfo类的典型用法代码示例。如果您正苦于以下问题:Java TopologyInfo类的具体用法?Java TopologyInfo怎么用?Java TopologyInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TopologyInfo类属于backtype.storm.generated包,在下文中一共展示了TopologyInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTopologyTPS
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
protected long getTopologyTPS(TopologySummary topology, Client client) throws NotAliveException, TException{
long topologyTps = 0l;
String topologyId = topology.get_id();
if(topologyId.startsWith("ClusterMonitor")){
return topologyTps;
}
TopologyInfo topologyInfo = client.getTopologyInfo(topologyId);
if(topologyInfo == null){
return topologyTps;
}
List<ExecutorSummary> executorSummaryList = topologyInfo.get_executors();
for(ExecutorSummary executor : executorSummaryList){
topologyTps += getComponentTPS(executor);
}
LOGGER.info("topology = " + topology.get_name() + ", tps = " + topologyTps);
return topologyTps;
}
示例2: checkAssignment
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Testing.
*
* @param topology the topology
*/
@SuppressWarnings("unused")
private void checkAssignment(TopologyInfo topology) {
CuratorFramework curator = connection.getCurator();
if (null != curator) {
try {
List<HostPort> hosts = HostPort.toHostPort(ZkUtils.getAliveWorkers(curator, topology),
HostPort.WORKERBEATS_HOSTPORT_PARSER);
System.out.println("ALIVE " + hosts);
Map<Integer, String> taskComponents = ZkUtils.taskComponentMapping(topology);
Map<String, List<TaskAssignment>> componentAssignments
= TaskAssignment.readTaskAssignments(ZkUtils.getAssignment(curator, topology), taskComponents);
System.out.println("ASSNG " + componentAssignments);
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例3: getExecutorHost
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Returns the host of the specific executor in the pipeline.
*
* @return the host of the executor (or <b>null</b> if not found)
*/
public String getExecutorHost() {
List<String> hosts = new ArrayList<String>();
TopologyInfo topologyInfo = getTopologyInfo(pipelineName);
if (topologyInfo != null) {
List<ExecutorSummary> executors = topologyInfo.get_executors();
for (int e = 0; e < executors.size(); e++) {
ExecutorSummary executor = executors.get(e);
String nodeName = executor.get_component_id();
if (nodeName.equals(executorName)) {
hosts.add(executor.get_host());
}
}
}
return shuffleHost(hosts);
}
示例4: main
import backtype.storm.generated.TopologyInfo; //导入依赖的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();
}
}
}
示例5: getComponentSummaries
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
private List<ComponentSummary> getComponentSummaries(TopologyInfo summ,
List<TaskSummary> ts) {
List<ComponentSummary> ret = new ArrayList<ComponentSummary>();
ComponentSummary cs = new ComponentSummary();
cs.setComponentId(componentid);
cs.setTopologyname(summ.get_name());
cs.setParallelism(String.valueOf(ts.size()));
ret.add(cs);
return ret;
}
示例6: taskSummaryTable
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
public List<TaskSumm> taskSummaryTable(TaskSummary task, TopologyInfo summ) {
List<TaskSumm> tsums = new ArrayList<TaskSumm>();
TaskSumm tsumm = new TaskSumm(String.valueOf(task.get_task_id()),
task.get_host(), String.valueOf(task.get_port()),
summ.get_name(), task.get_component_id(),
StatBuckets.prettyUptimeStr(task.get_uptime_secs()));
tsums.add(tsumm);
return tsums;
}
示例7: topologySummary
import backtype.storm.generated.TopologyInfo; //导入依赖的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;
}
示例8: main
import backtype.storm.generated.TopologyInfo; //导入依赖的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();
}
}
}
示例9: main
import backtype.storm.generated.TopologyInfo; //导入依赖的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();
}
}
}
示例10: main
import backtype.storm.generated.TopologyInfo; //导入依赖的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();
}
}
}
示例11: preparePipelineAggregation
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Prepares a topology for aggregation.
*
* @param topology the topology
* @param mapping the mapping
* @return the pipeline system part representing the pipeline
* @throws NotAliveException in case that the requested topology is not alive
* @throws TException in case of problems accessing the remote topology info
*/
private PipelineSystemPart preparePipelineAggregation(TopologyInfo topology, INameMapping mapping)
throws TException, NotAliveException {
SystemState state = getState();
String pipelineName = mapping.getPipelineName();
PipelineSystemPart part = state.obtainPipeline(pipelineName); // exists or creates
if (null == part.getTopology()) {
PipelineInfo info = MonitoringManager.getPipelineInfo(pipelineName);
Map<StormTopology, TopologyInfo> topologies = new HashMap<StormTopology, TopologyInfo>();
topologies.put(connection.getTopology(topology), topology);
for (PipelineInfo subInfo : info.getSubPipelines()) {
String subName = subInfo.getName();
try {
TopologyInfo si = connection.getTopologyInfoByName(subName);
topologies.put(connection.getTopology(si), si);
} catch (NotAliveException e) {
LOGGER.info("Sub-topology not alive: " + subName);
}
}
PipelineTopology topo = Utils.buildPipelineTopology(topologies, mapping);
part.setTopology(topo);
if (null != topo) {
LOGGER.info("TOPOLOGY for " + mapping.getPipelineName() + " " + topo);
}
}
if (PipelineLifecycleEvent.Status.INITIALIZED == part.getStatus() && !DataManager.isStarted()) {
if (System.currentTimeMillis() - part.getLastStateChange() // TODO WORKAROUND FOR DML
> MonitoringConfiguration.getPipelineStartNotificationDelay()) {
part.changeStatus(PipelineLifecycleEvent.Status.STARTED, true);
}
}
return part;
}
示例12: collectExecutors
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Collects a mapping of the actual executors.
*
* @param topoInfo the dynamic Storm topology information
* @return a mapping between the executor name and the executor information instance
*/
private static Map<String, ExecutorSummary> collectExecutors(TopologyInfo topoInfo) {
Map<String, ExecutorSummary> result = new HashMap<String, ExecutorSummary>();
List<ExecutorSummary> executors = topoInfo.get_executors();
if (null != executors) {
for (int e = 0; e < executors.size(); e++) {
ExecutorSummary executor = executors.get(e);
result.put(executor.get_component_id(), executor);
}
}
return result;
}
示例13: createTopology
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Creates a topology from multiple topology descriptors.
*
* @param main the main topology descriptor
* @param sub the sub topology descriptors
* @return the unified pipeline topology
*/
private static PipelineTopology createTopology(TopologyDescriptor main, TopologyDescriptor... sub) {
Map<StormTopology, TopologyInfo> topologies = new HashMap<StormTopology, TopologyInfo>();
topologies.put(main.topology, main.topoInfo);
for (TopologyDescriptor s : sub) {
topologies.put(s.topology, s.topoInfo);
}
return Utils.buildPipelineTopology(topologies, main.mapping);
}
示例14: addExecutors
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Adds pseudo-executors for testing to <code>topoInfo</code>. Avoids adding already known executors twice.
*
* @param topoInfo the information instance to be modified
* @param executors the names of the executors
*/
private static void addExecutors(TopologyInfo topoInfo, List<String> executors) {
Set<String> known = new HashSet<String>();
if (topoInfo.get_executors_size() > 0) {
for (ExecutorSummary e : topoInfo.get_executors()) {
known.add(e.get_component_id());
}
}
for (String n : executors) {
if (!known.contains(n)) {
topoInfo.add_to_executors(new ExecutorSummary(new ExecutorInfo(1, 1), n, "localhost", 1234, 10));
}
}
}
示例15: getAssignment
import backtype.storm.generated.TopologyInfo; //导入依赖的package包/类
/**
* Returns the assignment for the given <code>topology</code> from the zookeeper connection
* <code>framework</code>.
*
* @param framework the Curator framework connection to the Zookeeper
* @param topology the topology to set the assignment for
* @return the assignment for <code>topology</code>
* @throws IOException in case of writing problems
*/
public static Assignment getAssignment(CuratorFramework framework, TopologyInfo topology) throws IOException {
Assignment result = null;
try {
byte[] data = framework.getData().forPath(ASSIGNMENTS_PREFIX + topology.get_id());
Object o = Utils.deserialize(data);
if (o instanceof Assignment) {
result = (Assignment) o;
}
} catch (Exception e) {
throw new IOException(e.getMessage());
}
return result;
}