Storm Topology consists of two components:

Spout: The generator of data stream, the main data entry, acts as a collector, connects to the data source, converts the data into one tuple, and shoots Bolt with the tuple as data stream: Computation, which takes one data stream as input, executes operations on the data stream and optionally outputs one or more data streams. Bolt can subscribe to multiple data streams sent by SPout or other BoltsCopy the code

IComponent

All Spout, Bolt components need to implement the IComponent interface

Public interface IComponent extends Serializable {** * Storm component (spout, Bolt) must implement * Storm uses this method to tell Storm which streams the component will fire, and which fields each stream's tuple contains * @param outputFieldsDeclarer */ voiddeclareOutputFields(OutputFieldsDeclarer var1); Get fit information / * * * * / Map < String, Object > getComponentConfiguration (); }Copy the code

ISpout All spOUT components need to implement the ISpout interface

Public interface ISpout extends Serializable {/** * All Spout components call this method when initialized * @param map Map containing Storm configuration information * @param topologyContext Topology component information * @param spoutOutputCollector Void open(Map VAR1, TopologyContext var2, SpoutOutputCollector VAR3); */ void close(); void activate(); void deactivate(); /** * This is defined by the ISpout interface, the core of all spout implementations * Storm calls this method to issue a tuple to the output collector */ void nextTuple(); * @param msgId */ void ack(Object var1); /** * @param msgId unique identifier for each tuple */ void fail(Object var1); }Copy the code

IBolt Interface All Bolt components need to implement the IBolt interface

Public interface extends Serializable {/** * Public interface extends Serializable {/** * Public interface extends Serializable {/** * Public interface extends Serializable {/** * Public interface extends Serializable {/** * Public interface extends Serializable {/** * Public interface extends Serializable {/** * * @param map * @param topologyContext * @param outputCollector */ void prepare(map var1, topologyContext var2, OutputCollector var3); * @param tuple */ void execute(tuple var1); /** * Defined by the IBolt interface, Storm calls this method before terminating a bolt */ void cleanup(); }Copy the code

The advantage of using Storm development is that Storm has a local mode, which emulates a Storm cluster in a JVM instance. Greatly simplifies development and debugging in the development environment or IDE

The following attached word frequency statistics case source github.com/MarkGao1152…