好好爱自己!

With Storm Spouts, when is declareOutputFields( ) called?

The method IComponent.declareOutputFields(...) is called on the client machine when the client code calls createTopology() on the TopologyBuilder instance. Please look at the line 226 in the TopologyBuilder.java where this method gets called on the Spout or Bolt component(s).

The callback method IComponent.declareOutputFields(...) is part of the topology life cycle rather part of the Spout or Bolt life cycle. To answer your question, this method gets called before open()method.

The output fields should be declared in the declareOutputFields() method so that Storm serializes the Spout/Bolt object(s) including the configurations and output fields. The serialized instances of Spout/Bolt are then submitted to the Storm cluster after which the other life cycle methods (activate()open(), etc.) of Spout/Bolt are called.

posted @ 2017-08-17 17:38  立志做一个好的程序员  阅读(261)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处