Package backtype.storm.generated

Examples of backtype.storm.generated.ComponentCommon


        .getComponents(sysTopology);
    for (Entry<String, Object> entry : components.entrySet()) {
      String componentName = entry.getKey();
      Object component = entry.getValue();

      ComponentCommon common = null;
      if (component instanceof Bolt) {
        common = ((Bolt) component).get_common();
      }
      if (component instanceof SpoutSpec) {
        common = ((SpoutSpec) component).get_common();
      }
      if (component instanceof StateSpoutSpec) {
        common = ((StateSpoutSpec) component).get_common();
      }

      int hint = common.get_parallelism_hint();
      hintSum += hint;
    }

    if (settingNum == null) {
      return hintSum;
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;
      String componentType = "bolt";
      if (obj instanceof Bolt) {
        common = ((Bolt) obj).get_common();
        componentType = "bolt";
      } else if (obj instanceof SpoutSpec) {
View Full Code Here

  public int maxTopologyMessageTimeout() {
    Integer max = Utils.getInt(_stormConf
        .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) Utils.from_json(jsonConf);
        Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS);
        if (comp != null) {
          max = Math.max(Utils.getInt(comp), max);
View Full Code Here

  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));
View Full Code Here

          "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, Number parallelism) {
    ComponentCommon common = new ComponentCommon();
    common.set_inputs(new HashMap<GlobalStreamId, Grouping>());
    if (parallelism != null)
      common.set_parallelism_hint(parallelism.intValue());
    else {
        common.set_parallelism_hint(Integer.valueOf(1));
    }
    Map conf = component.getComponentConfiguration();
    if (conf != null)
      common.set_json_conf(Utils.to_json(conf));
    _commons.put(id, common);
  }
View Full Code Here

    // ACKER_ACK_STREAM_ID/ACKER_FAIL_STREAM_ID
    for (Entry<String, Bolt> e : ret.get_bolts().entrySet()) {

      Bolt bolt = e.getValue();

      ComponentCommon common = bolt.get_common();

      List<String> ackList = JStormUtils.mk_list("id", "ack-val");

      common.put_to_streams(ACKER_ACK_STREAM_ID,
          Thrift.outputFields(ackList));

      List<String> failList = JStormUtils.mk_list("id");
      common.put_to_streams(ACKER_FAIL_STREAM_ID,
          Thrift.outputFields(failList));

      bolt.set_common(common);
    }

    // add every spout output stream ACKER_INIT_STREAM_ID
    // add every spout two intput source
    // ((ACKER_COMPONENT_ID, ACKER_ACK_STREAM_ID), directGrouping)
    // ((ACKER_COMPONENT_ID, ACKER_FAIL_STREAM_ID), directGrouping)
    for (Entry<String, SpoutSpec> kv : ret.get_spouts().entrySet()) {
      SpoutSpec bolt = kv.getValue();
      ComponentCommon common = bolt.get_common();
      List<String> initList = JStormUtils.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_COMPONENT_ID, acker_bolt);
  }
View Full Code Here

  }

  private static List<String> sysEventFields = JStormUtils.mk_list("event");

  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);
    }
  }
View Full Code Here

   * @return component's configurations
   */
  public static Map getComponentMap(DefaultTopologyAssignContext context,
      Integer task) {
    String componentName = context.getTaskToComponent().get(task);
    ComponentCommon componentCommon = ThriftTopologyUtils
        .getComponentCommon(context.getSysTopology(), componentName);

    Map componentMap = (Map) JStormUtils.from_json(componentCommon
        .get_json_conf());
    if (componentMap == null) {
      componentMap = Maps.newHashMap();
    }
    return componentMap;
View Full Code Here

          .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

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.