Storm often uses classes

Source: Internet
Author: User
Tags emit

Get
<dependency><groupid>org.apache.storm</groupid><artifactid>storm-core</artifactid ><version>0.9.5</version></dependency>

Class backtype.storm.topology are often used.Topologybuilder
Used to build topology.


SpoutDeclareR backtype.storm.topology.TopologyBuilder. Setspout (String ID, irichspout spout, number Parallelism_hint)
Set spout for topology. Parallelism_hint is the number of tasks that will run this spout. Each task corresponds to a thread.


Boltdeclare R backtype.storm.topology.topologybuilder.< Span style= "COLOR: #ff0000" >setbolt (String ID, Irichbolt bolt, number Parallelism_hint)
sets the bolt to topology.

Backtype.storm. Config
This class has a series of member methods. Used to set the appropriate number of parameters.

void Backtype.storm.stormsubmitter. Submittopology (String name, Map stormconf, stormtopology topology)  
commits topology to the storm cluster.
Backtype.storm.topology. icomponent
An interface that indicates the components of the topology. void Backtype.storm.topology.IComponent. declare outputfields (Outputfieldsdeclare R declare R)
declares the output mode of all stream currently topology.

Backtype.storm.topology. outputfieldsDeclareR
The declarator for the output field.

void Backtype.storm.topology.OutputFieldsDeclareR.Declare(Fields)
Declared with the default stream ID.

void Backtype.storm.topology.OutputFieldsDeclarer. Declarestream (String streamid, fields)
Declares with field with the specified stream ID
Backtype.storm.task. Topologycontext
A topologycontext is passed to bolt and spout in the open () method of the Bolt's prepare () and spout. This class includes the location information of the component within the topology, such as the task ID, input and output, and so on.


List<integer> Backtype.storm.spout.SpoutOutputCollector. Emit (list<object> tuple)
Squirting a tuple to the default output stream. This steam does not have a message ID, so storm has no way to track it, so the ACK () and fail () methods will never be called for this tuple.


List<integer> Backtype.storm.task.OutputCollector.Emit(tuple anchor, list<object> tuple)
Jet a new tuple to the default anchor on a single tuple stream.

Tuplebacktype.storm.tuple.Tuple
A tuple is one of the main data structures in storm, the basic unit for sending messages between the spout and the Lightning. It is a list of values named, each of which can be of a random type.
Backtype.storm.tuple.Fields. Fields(String ... fields)
The constructor of the fields class. The list of shapes is (String ... fields).
A tuple in debugging is shown in Figure 1. Figure 1: A tupleSpoutbacktype.storm.spout in debugging.Ispout
This is the core interface of the Spout class. It has several methods.
void Backtype.storm.spout.ISpout.Open(Map conf, topologycontext context, spoutoutputcollector collector)
The function is called when the task of the component is initialized within a worker in the cluster. It provides the spout with the environment in which the spout runs.
void Backtype.storm.spout.ISpout.Close()
This method gets called when spout is closed. void Backtype.storm.spout.ISpout.Activate() Called when the spout from the suppressed state to the active state.

void Backtype.storm.spout.ISpout. Deactivate () Called when Spout is suppressed. Its nexttuple () method is not called at this time.
void Backtype.storm.spout.ISpout. Nexttuple ()
When the method is called, Spoutoutputcollector is required to spray a tuple.


void Backtype.storm.spout.ISpout. ack (Object msgId)
Indicates that a tuple with messageid from this spout has been completely processed.

A typical implementation of this method is to remove messages from the queue. Avoid being dealt with again.


void Backtype.storm.spout.ISpout. fail (Object msgId)
Indicates that a tuple with messageid from this spout has not been fully processed. A typical implementation of this method is to put the message in the queue again so that it can be sent again.



Backtype.storm.topology. Irichspout
Inherit from Ispout and IComponent.
Backtype.storm.spout. Spoutoutputcollector
A tuple injection for spout. Pay attention to the difference with Backtype.storm.task.OutputCollector. List<integer> Backtype.storm.spout.SpoutOutputCollector. Emit (list<object> tuple)
Squirting a tuple to the default output stream, this steam has no message ID, so storm has no way to track it. Therefore, the ACK () and fail () methods will never be called for this tuple.


Boltbacktype.storm.task. IBolt
This is the core interface of the Bolt class.

There are several methods: void Backtype.storm.task.IBolt. Prepare (Map stormconf, Topologycontext context, outputcollector collector)
When the task of this component is initialized within a worker in the cluster. The function is called. It provides the bolt with the environment in which the bolt runs.

void Backtype.storm.task.IBolt. Execute (Tuple input)
A single tuple that handles the input.

Backtype.storm.topology. Irichbolt

Inherit from Ibolt and IComponent.


Backtype.storm.task. Outputcollector
The output collector is used to emit a tuple from the Irichbolt.

List<integer> Backtype.storm.task.OutputCollector. Emit (tuple anchor, list<object> tuple)
Jet a new tuple to the default anchor on a single tuple stream.

List<integer> Backtype.storm.task.OutputCollector. Emit (String Streamid, list<object> tuple)

Sprays the data into the specified stream.

Backtype.storm.topology.InputDeclareR.shufflegrouping(String ComponentID)
Used to declare the output of which spout or bolts are received as input to the bolt.


BoltDeclareR backtype.storm.topology.InputDeclarer. localorshufflegrouping (String ComponentID)

Used to declare the output of which spout or bolts are received as input to the bolt.
Boltdeclarer Backtype.storm.topology.InputDeclarer. fieldsgrouping (String ComponentID, String streamid, fields)

Used to declare the specified fields of the specified stream that receive the specified spout or bolt as input to the bolt.
Boltdeclarer Backtype.storm.topology.InputDeclarer. allgrouping (String ComponentID, String streamid)

Used to declare the specified stream that receives the specified spout or bolt as input to the bolt.


Sample Example

Storm often uses classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.