Search in sources :

Example 6 with Grouping

use of backtype.storm.generated.Grouping in project storm by nathanmarz.

the class TopologyBuilder method initCommon.

private void initCommon(String id, IComponent component, Number parallelism) {
    ComponentCommon common = new ComponentCommon();
    common.set_inputs(new HashMap<GlobalStreamId, Grouping>());
    if (parallelism != null)
        common.set_parallelism_hint(parallelism.intValue());
    Map conf = component.getComponentConfiguration();
    if (conf != null)
        common.set_json_conf(JSONValue.toJSONString(conf));
    _commons.put(id, common);
}
Also used : ComponentCommon(backtype.storm.generated.ComponentCommon) GlobalStreamId(backtype.storm.generated.GlobalStreamId) Grouping(backtype.storm.generated.Grouping) CustomStreamGrouping(backtype.storm.grouping.CustomStreamGrouping) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with Grouping

use of backtype.storm.generated.Grouping in project storm by nathanmarz.

the class GeneralTopologyContext method getTargets.

/**
     * 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;
}
Also used : HashMap(java.util.HashMap) GlobalStreamId(backtype.storm.generated.GlobalStreamId) Grouping(backtype.storm.generated.Grouping) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Grouping (backtype.storm.generated.Grouping)7 GlobalStreamId (backtype.storm.generated.GlobalStreamId)6 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ComponentCommon (backtype.storm.generated.ComponentCommon)2 CustomStreamGrouping (backtype.storm.grouping.CustomStreamGrouping)2 StormTopology (backtype.storm.generated.StormTopology)1 PartialKeyGrouping (backtype.storm.grouping.PartialKeyGrouping)1 TopologyContext (backtype.storm.task.TopologyContext)1