public Object getFieldValue(_Fields field) { switch (field) { case BOLT_OBJECT: return get_bolt_object(); case COMMON: return get_common(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case BOLT_OBJECT: return get_bolt_object(); case COMMON: return get_common(); } throw new IllegalStateException(); }
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; }
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; }
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; }
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; }
public static ComponentCommon getComponentCommon(StormTopology topology, String componentId) { for (StormTopology._Fields f : StormTopology.metaDataMap.keySet()) { Map<String, Object> componentMap = (Map<String, Object>) topology.getFieldValue(f); if (componentMap.containsKey(componentId)) { Object component = componentMap.get(componentId); if (component instanceof Bolt) { return ((Bolt) component).get_common(); } if (component instanceof SpoutSpec) { return ((SpoutSpec) component).get_common(); } if (component instanceof StateSpoutSpec) { return ((StateSpoutSpec) component).get_common(); } throw new RuntimeException("Unreachable code! No get_common conversion for component " + component); } } throw new IllegalArgumentException("Could not find component common for " + componentId); } }
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; }
public static ComponentCommon getComponentCommon(StormTopology topology, String id) { if (topology.get_spouts().containsKey(id)) { return topology.get_spouts().get(id).get_common(); } if (topology.get_bolts().containsKey(id)) { return topology.get_bolts().get(id).get_common(); } if (topology.get_state_spouts().containsKey(id)) { return topology.get_state_spouts().get(id).get_common(); } throw new IllegalArgumentException("Could not find component with id " + id); }
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(); 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<>();
public static ComponentCommon getComponentCommon(StormTopology topology, String componentId) { for(StormTopology._Fields f: StormTopology.metaDataMap.keySet()) { Map<String, Object> componentMap = (Map<String, Object>) topology.getFieldValue(f); if(componentMap.containsKey(componentId)) { Object component = componentMap.get(componentId); if(component instanceof Bolt) { return ((Bolt) component).get_common(); } if(component instanceof SpoutSpec) { return ((SpoutSpec) component).get_common(); } if(component instanceof StateSpoutSpec) { return ((StateSpoutSpec) component).get_common(); } throw new RuntimeException("Unreachable code! No get_common conversion for component " + component); } } throw new IllegalArgumentException("Could not find component common for " + componentId); } }
ComponentCommon common = null; if (obj instanceof Bolt) { common = ((Bolt) obj).get_common();
Map<String, Set<String>> relationship = new HashMap<>(); for (Entry<String, Bolt> entry : context.getRawTopology().get_bolts().entrySet()) { Map<GlobalStreamId, Grouping> inputs = entry.getValue().get_common().get_inputs(); Set<String> input = new HashSet<>(); relationship.put(entry.getKey(), input);
String componentType = "bolt"; if (obj instanceof Bolt) { common = ((Bolt) obj).get_common(); componentType = "bolt"; } else if (obj instanceof SpoutSpec) {
public static ComponentCommon getComponentCommon(StormTopology topology, String id) { if (topology.get_spouts().containsKey(id)) { return topology.get_spouts().get(id).get_common(); } if (topology.get_bolts().containsKey(id)) { return topology.get_bolts().get(id).get_common(); } if (topology.get_state_spouts().containsKey(id)) { return topology.get_state_spouts().get(id).get_common(); } throw new IllegalArgumentException("Could not find component with id " + id); }
private static void add_component_system_streams(Object obj) { ComponentCommon common = null; if (obj instanceof StateSpoutSpec) { StateSpoutSpec spec = (StateSpoutSpec) obj; common = spec.get_common(); } if (obj instanceof SpoutSpec) { SpoutSpec spec = (SpoutSpec) obj; common = spec.get_common(); } if (obj instanceof Bolt) { Bolt spec = (Bolt) obj; common = spec.get_common(); } if (common != null) { StreamInfo sinfo = Thrift.outputFields(sysEventFields); common.put_to_streams(SYSTEM_STREAM_ID, sinfo); } }
common = ((Bolt) component).get_common();
static void add_component_system_streams(Object obj) { ComponentCommon common=null; if (obj instanceof StateSpoutSpec) { StateSpoutSpec spec = (StateSpoutSpec) obj; common=spec.get_common(); } if (obj instanceof SpoutSpec) { SpoutSpec spec = (SpoutSpec) obj; common=spec.get_common(); } if (obj instanceof Bolt) { Bolt spec = (Bolt) obj; common=spec.get_common(); } if(common!=null) { StreamInfo sinfo=Thrift.outputFields(sysEventFields); common.put_to_streams(SYSTEM_STREAM_ID,sinfo); } }
ComponentCommon common = bolt.get_common();
private static void validate_component(Object obj) throws InvalidTopologyException { if (obj instanceof StateSpoutSpec) { StateSpoutSpec spec = (StateSpoutSpec) obj; for (String id : spec.get_common().get_streams().keySet()) { if (system_id(id) || !charComponentValidate(id)) { throw new InvalidTopologyException(id + " is not a valid component id. " + compErrorInfo); } } } else if (obj instanceof SpoutSpec) { SpoutSpec spec = (SpoutSpec) obj; for (String id : spec.get_common().get_streams().keySet()) { if (system_id(id) || !charComponentValidate(id)) { throw new InvalidTopologyException(id + " is not a valid component id. " + compErrorInfo); } } } else if (obj instanceof Bolt) { Bolt spec = (Bolt) obj; for (String id : spec.get_common().get_streams().keySet()) { if (system_id(id) || !charComponentValidate(id)) { throw new InvalidTopologyException(id + " is not a valid component id. " + compErrorInfo); } } } else { throw new InvalidTopologyException("Unknown component type"); } }