Java Code Examples for backtype.storm.generated.StormTopology#get_bolts()
The following examples show how to use
backtype.storm.generated.StormTopology#get_bolts() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionCommon.java From jstorm with Apache License 2.0 | 6 votes |
public static Set<String> getDownstreamComponents(String componentId, StormTopology topology) { Set<String> components = new HashSet<>(); Map<String, Bolt> bolts = topology.get_bolts(); for (Entry<String, Bolt> entry : bolts.entrySet()) { String downstreamComponentId = entry.getKey(); Bolt bolt = entry.getValue(); Set<GlobalStreamId> input = bolt.get_common().get_inputs().keySet(); for (GlobalStreamId stream : input) { String upstreamComponentId = stream.get_componentId(); if (upstreamComponentId.equals(componentId)) { components.add(downstreamComponentId); break; } } } return components; }
Example 2
Source File: TransactionCommon.java From jstorm with Apache License 2.0 | 6 votes |
public static Set<String> getAllDownstreamComponents(String componentId, StormTopology topology, Set<String> traversedComponents) { Set<String> components = new HashSet<>(); traversedComponents.add(componentId); Map<String, Bolt> bolts = topology.get_bolts(); for (Entry<String, Bolt> entry : bolts.entrySet()) { String downstreamComponentId = entry.getKey(); Bolt bolt = entry.getValue(); Set<GlobalStreamId> input = bolt.get_common().get_inputs().keySet(); for (GlobalStreamId stream : input) { String upstreamComponentId = stream.get_componentId(); if (upstreamComponentId.equals(componentId) && !traversedComponents.contains(downstreamComponentId)) { components.add(downstreamComponentId); components.addAll(getAllDownstreamComponents(downstreamComponentId, topology, traversedComponents)); break; } } } return components; }
Example 3
Source File: TransactionCommon.java From jstorm with Apache License 2.0 | 6 votes |
public static Set<Integer> getDownstreamTasks(String componentId, TopologyContext context) { Set<Integer> tasks = new HashSet<>(); StormTopology topology = context.getRawTopology(); Map<String, Bolt> bolts = topology.get_bolts(); for (Entry<String, Bolt> entry : bolts.entrySet()) { String downstreamComponentId = entry.getKey(); Bolt bolt = entry.getValue(); Set<GlobalStreamId> input = bolt.get_common().get_inputs().keySet(); for (GlobalStreamId stream : input) { String upstreamComponentId = stream.get_componentId(); if (upstreamComponentId.equals(componentId)) { tasks.addAll(context.getComponentTasks(downstreamComponentId)); break; } } } return tasks; }
Example 4
Source File: TransactionCommon.java From jstorm with Apache License 2.0 | 6 votes |
public static Set<String> getEndBolts(StormTopology topology) { Set<String> endBolts = new HashSet<>(); Map<String, Bolt> bolts = topology.get_bolts(); for (Entry<String, Bolt> entry : bolts.entrySet()) { String componentId = entry.getKey(); Bolt bolt = entry.getValue(); Map<String, StreamInfo> outputStreams = bolt.get_common().get_streams(); if (outputStreams.size() == 0) { endBolts.add(entry.getKey()); } else { // Try to check if there is any "real" downstream for the output stream boolean found = false; for (String streamId : outputStreams.keySet()) { if (hasDownstreamComponent(topology, componentId, streamId)) { found = true; break; } } if (!found) endBolts.add(entry.getKey()); } } return endBolts; }
Example 5
Source File: DoRebalanceTransitionCallback.java From jstorm with Apache License 2.0 | 5 votes |
private int setBoltInfo(StormTopology oldTopology, StormTopology newTopology, int cnt, StormClusterState clusterState) throws Exception { Map<String, Bolt> oldBolts = oldTopology.get_bolts(); Map<String, Bolt> bolts = newTopology.get_bolts(); for (Entry<String, Bolt> entry : oldBolts.entrySet()) { String boltName = entry.getKey(); Bolt oldBolt = entry.getValue(); Bolt bolt = bolts.get(boltName); if (oldBolt.get_common().get_parallelism_hint() > bolt.get_common().get_parallelism_hint()) { int removedTaskNum = oldBolt.get_common().get_parallelism_hint() - bolt.get_common().get_parallelism_hint(); TreeSet<Integer> taskIds = new TreeSet<>(clusterState.task_ids_by_componentId(topologyId, boltName)); Iterator<Integer> descendIterator = taskIds.descendingIterator(); while (--removedTaskNum >= 0) { int taskId = descendIterator.next(); removeTask(topologyId, taskId, clusterState); LOG.info("Remove bolt task, taskId=" + taskId + " for " + boltName); } } else if (oldBolt.get_common().get_parallelism_hint() == bolt.get_common().get_parallelism_hint()) { continue; } else { int delta = bolt.get_common().get_parallelism_hint() - oldBolt.get_common().get_parallelism_hint(); Map<Integer, TaskInfo> taskInfoMap = new HashMap<>(); for (int i = 1; i <= delta; i++) { cnt++; TaskInfo taskInfo = new TaskInfo(entry.getKey(), "bolt"); taskInfoMap.put(cnt, taskInfo); newTasks.add(cnt); LOG.info("Setup new bolt task, taskId=" + cnt + " for " + boltName); } clusterState.add_task(topologyId, taskInfoMap); } } return cnt; }
Example 6
Source File: TransactionCommon.java From jstorm with Apache License 2.0 | 5 votes |
public static Set<String> getStatefulBolts(StormTopology topology) { Set<String> statefulBolts = new HashSet<>(); Map<String, Bolt> bolts = topology.get_bolts(); for (Entry<String, Bolt> entry : bolts.entrySet()) { Bolt bolt = entry.getValue(); Map conf = JStormUtils.parseJson(bolt.get_common().get_json_conf()); if (JStormUtils.parseBoolean(conf.get(TRANSACTION_STATEFUL_BOLT), false)) { statefulBolts.add(entry.getKey()); } } return statefulBolts; }