Package backtype.storm.generated

Examples of backtype.storm.generated.ComponentCommon


    public StormTopology createTopology() {
        Map<String, Bolt> boltSpecs = new HashMap<String, Bolt>();
        Map<String, SpoutSpec> spoutSpecs = new HashMap<String, SpoutSpec>();
        for(String boltId: _bolts.keySet()) {
            IRichBolt bolt = _bolts.get(boltId);
            ComponentCommon common = getComponentCommon(boltId, bolt);
            boltSpecs.put(boltId, new Bolt(ComponentObject.serialized_java(Utils.serialize(bolt)), common));
        }
        for(String spoutId: _spouts.keySet()) {
            IRichSpout spout = _spouts.get(spoutId);
            ComponentCommon common = getComponentCommon(spoutId, spout);
            spoutSpecs.put(spoutId, new SpoutSpec(ComponentObject.serialized_java(Utils.serialize(spout)), common));
           
        }
        return new StormTopology(spoutSpecs,
                                 boltSpecs,
View Full Code Here


            throw new IllegalArgumentException("State spout has already been declared for id " + id);
        }
    }

    private ComponentCommon getComponentCommon(String id, IComponent component) {
        ComponentCommon ret = new ComponentCommon(_commons.get(id));
       
        OutputFieldsGetter getter = new OutputFieldsGetter();
        component.declareOutputFields(getter);
        ret.set_streams(getter.getFieldsDeclaration());
        return ret;       
    }
View Full Code Here

        ret.set_streams(getter.getFieldsDeclaration());
        return ret;       
    }
   
    private void initCommon(String id, IComponent component, Integer parallelism) {
        ComponentCommon common = new ComponentCommon();
        common.set_inputs(new HashMap<GlobalStreamId, Grouping>());
        if(parallelism!=null) common.set_parallelism_hint(parallelism);
        Map conf = component.getComponentConfiguration();
        if(conf!=null) common.set_json_conf(JSONValue.toJSONString(conf));
        _commons.put(id, common);
    }
View Full Code Here

    }
   
    public int maxTopologyMessageTimeout(Map<String, Object> topologyConfig) {
        Integer max = Utils.getInt(topologyConfig.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS));
        for(String spout: getRawTopology().get_spouts().keySet()) {
            ComponentCommon common = getComponentCommon(spout);
            String jsonConf = common.get_json_conf();
            if(jsonConf!=null) {
                Map conf = (Map) JSONValue.parse(jsonConf);
                Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS);
                if(comp!=null) {
                    max = Math.max(Utils.getInt(comp), max);
View Full Code Here

    }
    Set<?> entrySet = cidSpec.entrySet();
    for (Iterator<?> it = entrySet.iterator(); it.hasNext();) {
      Entry entry = (Entry) it.next();
      Object obj = entry.getValue();
      ComponentCommon common = null;
      if (obj instanceof Bolt) {
        common = ((Bolt) obj).get_common();

      } else if (obj instanceof SpoutSpec) {
        common = ((SpoutSpec) obj).get_common();
View Full Code Here

            List<String> componentNames = new ArrayList<String>(topology.get_spouts().keySet());
            componentNames.addAll(topology.get_bolts().keySet());
            componentNames.addAll(topology.get_state_spouts().keySet());
                       
            for(String name: componentNames) {
                ComponentCommon common = Utils.getComponentCommon(topology, name);
                List<String> streams = new ArrayList<String>(common.get_streams().keySet());
                streamNametoId.put(name, idify(streams));
                streamIdToName.put(name, Utils.reverseMap(streamNametoId.get(name)));
            }
        }
View Full Code Here

  }

  private static ComponentCommon mkAckerComponentcommon(
      Map<GlobalStreamId, Grouping> inputs,
      HashMap<String, StreamInfo> output_spec, Integer parallelism_hint) {
    ComponentCommon ret = new ComponentCommon(inputs, output_spec);
    if (parallelism_hint != null) {
      ret.set_parallelism_hint(parallelism_hint);
    }
    return ret;
  }
View Full Code Here

    return ret;
  }

  public static Bolt mkAckerBolt(Map<GlobalStreamId, Grouping> inputs,
      IBolt bolt, HashMap<String, StreamInfo> output, Integer p) {
    ComponentCommon common = mkAckerComponentcommon(inputs, output, p);
    byte[] boltSer = Utils.serialize(bolt);
    ComponentObject component = ComponentObject.serialized_java(boltSer);
    return new Bolt(component, common);
  }
View Full Code Here

    }
    Set<String> cids = ThriftTopologyUtils.getComponentIds(topology);
    List componentSers = new ArrayList();
    for (Iterator it = cids.iterator(); it.hasNext();) {
        String componentId = (String) it.next();
        ComponentCommon common = ThriftTopologyUtils.getComponentCommon(
          topology, componentId);
        String json = common.get_json_conf();
        if (json != null){
            Map mtmp = (Map) StormUtils.from_json(json);
            List ltmp = (List) mtmp.get(Config.TOPOLOGY_KRYO_REGISTER);
            componentSers.add(ltmp);
        }
View Full Code Here

      IBolt ackerbolt= new Acker();
      Map<GlobalStreamId, Grouping> inputs=acker_inputs(ret);
      Bolt acker_bolt = Thrift.mkAckerBolt(inputs, ackerbolt, outputs, num_tasks);
      for (Entry<String, Bolt> e : ret.get_bolts().entrySet()) {
          Bolt bolt = e.getValue();
          ComponentCommon common = bolt.get_common();
          List<String> ackList = StormUtils.mk_list("id", "ack-val");
          common.put_to_streams(ACKER_ACK_STREAM_ID,Thrift.outputFields(ackList));
         
          List<String> failList = StormUtils.mk_list("id");
          common.put_to_streams(ACKER_FAIL_STREAM_ID,Thrift.outputFields(failList));
          bolt.set_common(common);
      }
 
      for (Entry<String, SpoutSpec> kv : ret.get_spouts().entrySet()) {
          SpoutSpec bolt = kv.getValue();
          ComponentCommon common = bolt.get_common();
          List<String> initList = StormUtils.mk_list("id", "init-val", "spout-task");
          common.put_to_streams(ACKER_INIT_STREAM_ID,Thrift.outputFields(initList));
         
          GlobalStreamId ack_ack=new GlobalStreamId(ACKER_COMPONENT_ID, ACKER_ACK_STREAM_ID);
          common.put_to_inputs(ack_ack, Thrift.mkDirectGrouping());
         
          GlobalStreamId ack_fail=new GlobalStreamId(ACKER_COMPONENT_ID,ACKER_FAIL_STREAM_ID);
          common.put_to_inputs(ack_fail,Thrift.mkDirectGrouping());
      }
 
      ret.put_to_bolts("__acker", acker_bolt);
  }
View Full Code Here

TOP

Related Classes of backtype.storm.generated.ComponentCommon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.