Storm common classes

Source: Internet
Author: User
Tags emit

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

Common class backtype.storm.topology.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 be performed for this spout, and each task corresponds to a thread.
Boltdeclarer Backtype.storm.topology.TopologyBuilder.Setbolt(String ID, Irichbolt bolt, number Parallelism_hint)
Set up bolts for topology.

Backtype.storm.Config
This class has a series of member methods that are used to set the corresponding parameters.

void Backtype.storm.StormSubmitter.submittopology(String name, Map stormconf, stormtopology topology)
Submit topology to the Storm cluster.
Backtype.storm.topology.IComponent
An interface that indicates the components of the topology. void Backtype.storm.topology.IComponent.Declareoutputfields(Outputfieldsdeclarer declarer)
Declares the output mode of all streams that are currently topology.
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 contains 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 into the default output stream, this steam has no message ID, so storm has no way to track, 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 and is the basic unit for sending messages between the spout and lightning. It is a list of values that are named, where each value can be any type.
Backtype.storm.tuple.Fields. Fields(String ... fields)
The constructor of the fields class, the parameter list 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 that the spout executes.
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)
A tuple with MessageID that is injected from this spout has been fully processed. A typical implementation of this method is to remove the message from the queue and avoid being processed again.
void Backtype.storm.spout.ISpout.fail(Object msgId)
Indicates that a tuple with messageid from this spout is not 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. Note the difference from Backtype.storm.task.OutputCollector. List<integer> Backtype.storm.spout.SpoutOutputCollector.Emit(list<object> tuple)
Squirting a tuple into the default output stream, this steam has no message ID, so storm has no way to track, so 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 ways to do this: void Backtype.storm.task.IBolt.Prepare(Map stormconf, Topologycontext context, outputcollector collector)
The function is called when the task of the component is initialized within a worker in the cluster. It provides the bolts with the environment that the bolt executes. 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.

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

Example

Storm common 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.