@Override public String getStream() { return stream.get_streamId(); } });
public static Set<String> getInputStreamIds(TopologyContext context) { Set<String> ret = new HashSet<>(); Set<GlobalStreamId> inputs = context.getThisSources().keySet(); for (GlobalStreamId streamId : inputs) { ret.add(streamId.get_streamId()); } return ret; }
public Object getFieldValue(_Fields field) { switch (field) { case COMPONENT_ID: return get_componentId(); case STREAM_ID: return get_streamId(); } throw new IllegalStateException(); }
private Set<GlobalStreamId> getComponentStreams(TopologyContext context) { Set<GlobalStreamId> streams = new HashSet<>(); for (GlobalStreamId streamId : context.getThisSources().keySet()) { if (!streamId.get_streamId().equals(CheckpointSpout.CHECKPOINT_STREAM_ID)) { streams.add(streamId); } } return streams; }
public Object getFieldValue(_Fields field) { switch (field) { case COMPONENT_ID: return get_componentId(); case STREAM_ID: return get_streamId(); } throw new IllegalStateException(); }
private Fields getSourceOutputFields(TopologyContext context, String sourceStream) { for (GlobalStreamId g : context.getThisSources().keySet()) { if (g.get_streamId().equals(sourceStream)) { return context.getComponentOutputFields(g); } } throw new RuntimeException("Could not find fields for source stream " + sourceStream); }
/** * returns the total number of input checkpoint streams across * all input tasks to this component. */ private int getCheckpointInputTaskCount(TopologyContext context) { int count = 0; for (GlobalStreamId inputStream : context.getThisSources().keySet()) { if (CheckpointSpout.CHECKPOINT_STREAM_ID.equals(inputStream.get_streamId())) { count += context.getComponentTasks(inputStream.get_componentId()).size(); } } return count; }
/** * Gets information about who is consuming the outputs of the specified component, and how. * * @return Map from stream id to component id to the Grouping used. */ public Map<String, Map<String, Grouping>> getTargets(String componentId) { Map<String, Map<String, Grouping>> ret = new HashMap<>(); for (String otherComponentId : getComponentIds()) { Map<GlobalStreamId, Grouping> inputs = getComponentCommon(otherComponentId).get_inputs(); for (GlobalStreamId id : inputs.keySet()) { if (id.get_componentId().equals(componentId)) { Map<String, Grouping> curr = ret.get(id.get_streamId()); if (curr == null) curr = new HashMap<>(); curr.put(otherComponentId, inputs.get(id)); ret.put(id.get_streamId(), curr); } } } return ret; }
/** * Gets the declared output fields for the specified global stream id. */ public Fields getComponentOutputFields(GlobalStreamId id) { return getComponentOutputFields(id.get_componentId(), id.get_streamId()); }
@Override public BoltDeclarer grouping(GlobalStreamId id, Grouping grouping) { return grouping(id.get_componentId(), id.get_streamId(), grouping); } }
private static boolean hasDownstreamComponent(StormTopology topology, String outComponentId, String outStreamId) { boolean ret = false; for (String componentId : ThriftTopologyUtils.getComponentIds(topology)) { ComponentCommon componentCommon = Utils.getComponentCommon(topology, componentId); Set<GlobalStreamId> inputs = componentCommon.get_inputs().keySet(); for (GlobalStreamId input : inputs) { if (input.get_componentId().equals(outComponentId) && input.get_streamId().equals(outStreamId)) return true; } } return ret; } }
@Override public BoltDeclarer grouping(GlobalStreamId id, Grouping grouping) { return grouping(id.get_componentId(), id.get_streamId(), grouping); } }
/** * Gets information about who is consuming the outputs of the specified component, * and how. * * @return Map from stream id to component id to the Grouping used. */ public Map<String, Map<String, Grouping>> getTargets(String componentId) { Map<String, Map<String, Grouping>> ret = new HashMap<String, Map<String, Grouping>>(); for(String otherComponentId: getComponentIds()) { Map<GlobalStreamId, Grouping> inputs = getComponentCommon(otherComponentId).get_inputs(); for(GlobalStreamId id: inputs.keySet()) { if(id.get_componentId().equals(componentId)) { Map<String, Grouping> curr = ret.get(id.get_streamId()); if(curr==null) curr = new HashMap<String, Grouping>(); curr.put(otherComponentId, inputs.get(id)); ret.put(id.get_streamId(), curr); } } } return ret; }
/** * Gets the declared output fields for the specified global stream id. */ public Fields getComponentOutputFields(GlobalStreamId id) { return getComponentOutputFields(id.get_componentId(), id.get_streamId()); }
stringSources.put(gid.get_componentId(), stringSourceMap); stringSourceMap.put(gid.get_streamId(), groupingToJSONableMap(entry.getValue()));
Set<String> idFields = null; for (GlobalStreamId source : context.getThisSources().keySet()) { Fields fields = context.getComponentOutputFields(source.get_componentId(), source.get_streamId()); Set<String> setFields = new HashSet<String>(fields.toList()); if (idFields == null)
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { createState(context); prepare(stormConf, context, collector, keyRangeState); Map<GlobalStreamId, Grouping> sources = context.getSources(context.getThisComponentId()); for (Map.Entry<GlobalStreamId, Grouping> entry : sources.entrySet()) { GlobalStreamId stream = entry.getKey(); Grouping grouping = entry.getValue(); Grouping._Fields groupingFields = Thrift.groupingType(grouping); if (Grouping._Fields.FIELDS.equals(groupingFields)) { Fields fields = new Fields(Thrift.fieldGrouping(grouping)); fieldGrouping.put(stream.get_streamId(), fields); } } LOG.info("Source fieldgrouping streams: {}", fieldGrouping); }
Set<GlobalStreamId> inputs = topologyContext.getThisSources().keySet(); for (GlobalStreamId stream : inputs) { inputStreamIds.add(streamIds.getStreamId(stream.get_componentId(), stream.get_streamId()));
@Override public String getStream() { return stream.get_streamId(); } });
public Object getFieldValue(_Fields field) { switch (field) { case COMPONENT_ID: return get_componentId(); case STREAM_ID: return get_streamId(); } throw new IllegalStateException(); }