Storm学习00--IComponent

来源:互联网 发布:手机处理数据作图软件 编辑:程序博客网 时间:2024/05/21 12:43

##IComponent
IComponent继承Serializable接口, 为topology中所有可能组件提供共同的方法。

 interface IComponent extends Serializable

提供两个方法

/** * Common methods for all possible components in a topology. This interface is used * when defining topologies using the Java API.  */public interface IComponent extends Serializable {    /**     * Declare the output schema for all the streams of this topology.     *     * @param declarer this is used to declare output stream ids, output fields, and whether or not each output stream is a direct stream     */    void declareOutputFields(OutputFieldsDeclarer declarer);    /**     * Declare configuration specific to this component. Only a subset of the "topology.*" configs can     * be overridden. The component configuration can be further overridden when constructing the      * topology using {@link TopologyBuilder}     *     */    Map<String, Object> getComponentConfiguration();}

1.1 declareOutputFields(OutputFieldsDeclarer declarer)

  此方法用于声明当前Spout的Tuple发送流。Stream流的定义是通过OutputFieldsDeclarer.declare方法完成的,其中的参数包括了发送的域Fields。
如: 在RandomSentenceSpout中重写了

  @Override  public void declareOutputFields(OutputFieldsDeclarer declarer) {    declarer.declare(new Fields("word"));}  

1.2 getComponentConfiguration();

 &mesp;此方法用于声明针对当前组件的特殊的Configuration配置。

这里写图片描述

0 0
原创粉丝点击