Storm学习00--IComponent

    xiaoxiao2021-03-25  71

    ##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配置。

    转载请注明原文地址: https://ju.6miu.com/read-36794.html

    最新回复(0)