Storm (ii) basic terminology of storm

Source: Internet
Author: User
Tags ack arrays emit joins requires serialization shuffle
topologies

The logic for a realtime application was packaged into a Storm topology. A Storm topology is analogous to a MapReduce job. One key difference is the a MapReduce job eventually finishes, whereas a topology runs forever (or until you kill it, of Course). A topology is a graph of spouts and bolts that was connected with stream groupings. These concepts is described below.

all the logic of the application is packaged into Storm's topology. Storm's topology is similar to the job of MapReduce. One of the differences between the two is that Mr's job will end up running, and topology will keep running until the man-made kill is killed. The grouping of spouts, bolts, and data streams is defined in topology.

Resources: Topologybuilder: Use the This class to construct topologies in Java Cluster: Running topologies on a product Ion Cluster Local mode: Read this to learn how to develop and test topologies in local mode. Streams

The stream is the core abstraction in Storm. A Stream is an unbounded sequence of tuples which is processed and created in parallel in a distributed fashion. Streams is defined with a schema, the names the fields in the stream ' s tuples. By default, tuples can contain integers, longs, shorts, bytes, strings, doubles, floats, booleans, and byte arrays. You can also define your own serializers so, custom types can be used natively within tuples.

Stream is the core concept of storm. Stream is a non-boundary tuple sequence that can be created and processed in parallel in a distributed scenario. You can use schema to define the fields of the tuple passed in the stream. By default, a tuple can contain integers, longs, shorts, bytes, strings, doubles, floats, booleans, and byte arrays. You can also customize your own serialization object types.

Every stream is given a ID when declared. Since Single-stream spouts and bolts is so common, outputfieldsdeclarer have convenience methods for declaring a single St Ream without specifying an ID. The stream is given the default ID of "default".

each stream needs to be given an ID at the time of declaration. But since Single-stream spouts and bolts are more commonly used, Outputfieldsdeclarer has a more convenient way to declare a stream without specifying an ID, in which case the default ID is ' Default '.

Resources: Tuple: Streams is composed of tuples Outputfieldsdeclarer: Used to declare streams and their schemas serialization: Information about Storm ' s dynamic typing of tuples and declaring custom serializations Iserializ ation: Custom serializers must implement this interface CONFIG. Topology_serializations: Custom serializers can be registered using the This configuration spouts

A spout is a source of streams in a topology. Generally spouts would read tuples from an external source and emit them into the topology (e.g. a Kestrel queue or the TWI Tter API). Spouts can either be reliable or unreliable. A reliable spout is capable of replaying a tuple if it failed to being processed by Storm, whereas an unreliable spout forget s about the tuple as soon as it is emitted.

Spout is the source of the stream in topology. Typically spout reads tuples from an external data source and then emit to bolts in topology. spout can be reliable or unreliable. A reliable spout can be restored after a failure, and unreliable spout cannot do that.

Spouts can emit more than one stream. To does so, declare multiple streams using the Declarestream method of Outputfieldsdeclarer and specify the stream to emit t o When using the Emitmethod on Spoutoutputcollector.

spout can be emit to more than one stream. Declare multiple streams using the Declarestream method, and declare the specific emit to which stream when emit the data.

The main method on Spouts is nexttuple. Nexttuple either emits a new tuple into the topology or simply returns if there is no new tuples to emit. It is imperative this nexttuple does not block for any spout implementation, because Storm calls all the spout methods on The same thread.

the main method of spout is nexttuple. Nexttuple can emit a new tuple to topology or just return. In any spout implementation, the Nexttuple method does not block, because Storm is the method that calls spout in the same thread.

The other main methods on spouts is ACK and fail. These is called when Storm detects, a tuple emitted from the spout either successfully completed through the topology Or failed to is completed. Ack and fail is only called for reliable spouts. See the Javadoc for more information.

the other main methods in spout are ACK and fail. These two methods are triggered when the spout emit data succeeds or fails. ACK and fail are for reliable spout only.

Resources: Irichspout: This was the interface that spouts must implement. Guaranteeing message processing bolts

All processing in topologies are do in bolts. Bolts can do anything from filtering, functions, aggregations, joins, talking to databases, and more.
Bolts can do simple stream transformations. Doing complex stream transformations often requires multiple steps and thus multiple bolts. For example, transforming a stream of tweets-a stream of trending images requires at least the steps:a bolt to do a Rolling count of retweets for each image, and one or more bolts to stream out the top X images (you can do this particular Stream transformation in a more scalable a-to with three bolts than with both).

The logical processing of tuple in topology is in bolts. Bolts can do anything by filtering, functions, aggregations, joins, talking to databases. Bolts can be used to transform simple data streams, or to perform complex data flow transformations, and complex data flow transformations often require multiple bolts for data processing.

Bolts can emit more than one stream. To does so, declare multiple streams using the Declarestream method of Outputfieldsdeclarer and specify the stream to emit t o When using the emit method on Outputcollector.

bolts can be emit to more than one stream. Declare multiple streams using the Declarestream method, and declare a specific emit stream when emit data.

When you declare a bolts ' s input streams, you are always subscribe to specific streams of another component. If you want to subscribe to all the streams of another component, you have to subscribe to each one individually. Inputdeclarer have syntactic sugar for subscribing to streams declared on the default stream ID. Saying declarer.shufflegrouping ("1") subscribes to the default stream on component ' 1 ' and is equivalent TODECLARER.SHUFFL Egrouping ("1", default_stream_id).

when declaring an input stream for a bolt, you usually need to subscribe to the stream of another component. If you want to subscribe to all the streams of another component, you need to subscribe to each stream. The method of subscribing to stream with the ID of stream is declared in Inputdeclarer. Declarer.shufflegrouping ("1") subscribes to the default STREAM of another component "1", equivalent to Declarer.shufflegrouping ("1", default_stream_id).

The main method in bolts was the Execute method which takes in as input a new tuple. Bolts emit new tuples using the Outputcollector object. Bolts must call the Ack method on the outputcollector for every a tuple they process so this Storm knows when tuples is com Pleted (and can eventually determine that it safe to ack the original spout tuples). For the common case of processing a input tuple, emitting 0 or more tuples based on this tuple, and then acking the input Tuple, Storm provides an Ibasicbolt interface which does the acking automatically.

the primary method in bolts is execute, which takes a tuple as an input parameter. Bolts uses Outputcollector to emit a new tuple object. Bolts the Ack method of Outputcollector must be called for each tuple to be processed so that storm knows tuples is done. Usually when processing a tuple input, according to the actual situation emit 0 or more tuples, and then ack corresponding input tuple,storm provides Ibasicbolt interface to automatically complete the ACK mechanism.

Please note this outputcollector is not thread-safe, and all emits, acks, and fails must happen on the same thread. Refer troubleshooting for more details.

Outputcollector is not thread-safe, so all emits, acks, and fails must be in the same thread.

Resources: Irichbolt: This is the general interface for bolts. Ibasicbolt: This was a convenience interface for defining bolts that does filtering or simple functions. outputcollector: bolts emit tuples to their output streams using a instance of this class guaranteeing message P Rocessing Stream Groupings

Part of defining a topology are specifying for each bolt which streams it should receive as input. A Stream grouping defines how this stream should be partitioned among the bolt ' s tasks.

when defining topology, you need to declare for each bolt exactly which streams to accept as input. The grouping of streams defines how the stream's partition between the Bolts ' tasks.

There is eight built-in stream groupings in Storm, and you can implement a custom stream grouping by implementing the Cus Tomstreamgrouping Interface:

Here are 8 built-in stream grouping, and you can also customize the stream grouping by implementing the Customstreamgrouping interface. Shuffle Grouping:tuples is randomly distributed across the bolt's tasks in a-to-do such that each bolt was guaranteed to GE T an equal number of tuples.

The tuples is randomly distributed between the bolts tasks and ensures uniform distribution as far as possible.

Fields Grouping:the stream are partitioned by the fields specified in the grouping. For example, if the stream was grouped by the ' User-id ' field, tuples with the same "User-id" would always go to the same TA SK, but tuples with different "User-id" ' s could go to different tasks.**

Stream partition The stream based on the name of the variable defined in grouping, for example, the stream is grouped according to the "User-id" variable, so tuples has the same "User-id" will be assigned to the same task processing, and the different "User-id" will be assigned to different task handlers.

Partial Key grouping:the Stream is partitioned by the fields specified in the grouping, like the fields grouping, and are Load balanced between-downstream bolts, which provides better utilization of resources when the incoming data is skew Ed. This paper provides a good explanation of how it works and the advantages it provides.

Stream partition The stream based on the name of the variable defined in grouping, similar to the fields grouping, but in ...

All grouping:the stream are replicated across all the bolts ' s tasks. Use this grouping with care.

The stream is replicate in each task in bolts, meaning that each task receives the same tuple.

Global grouping:the entire stream goes to a single one of the Bolts ' s tasks. Specifically, it goes to the task with the lowest ID.

all the streams went to the bolts's lowest-ID task.

None grouping:this grouping Specifies that you don ' t care how the stream is grouped. Currently, none groupings is equivalent to shuffle groupings. Eventually though, Storm would push down bolts with none groupings-to-execute in the same thread as the bolt or spout they Subscribe from (when possible).

the current Nonoe grouping is equivalent to shuffle grouping.

Direct Grouping:this is a special kind of grouping. A stream grouped this to means that the producer of the tuple decides which task of the consumer would receive this tuple. Direct groupings can is declared on streams that has been declared as direct streams. Tuples emitted to a direct stream must is emitted using one of the Emitdirect methods. A Bolt can get the task IDs of its consumers by either using the Providedtopologycontext or by keeping track of the output Of the Emit method in Outputcollector (which returns, the task IDs that the tuple is sent to).

This is a special grouping. The stream uses this way to grouping means that the producer of a tuple determines which task receives the tuple. Direct grouping can only be used on a stream that has a direct stream already declared. The Emitdirect method must be used on a tuple emit to a direct stream. Bolts can use Topologycontext or trace the output of emit to get the task ID.

Local or shuffle grouping:if the target bolt have one or more tasks in the same worker process, tuples'll be shuffled to Just those in-process tasks. Otherwise, this acts like a normal shuffle grouping.

if the target bolt has one or more tasks,tuple in the same worker, it will only be assigned a tuple in the worker's task, otherwise the grouping is similar to shuffle grouping.

Resources: Topologybuilder: Use this class to define topologies Inputdeclarer: This object is returned whenever set Bolt is called on Topologybuilder and are used for declaring a bolts ' s input streams and how those streams should be grouped Coordinatedbolt: This bolt was useful for distributed RPC topologies and makes heavy use of direct streams and Di Rect groupings Reliability

Storm guarantees that every spout tuple would be a fully processed by the topology. It does the tracking the tree of tuples triggered by every spout tuples and determining when that tree of tuples have been En successfully completed. Every topology has a ' message timeout ' associated with it. If Storm fails to detect a spout tuple have been completed within that timeout, then it fails the tuple and replays it Later.

storm ensures that every tuple will be topology. Topology determines whether a tuple is successfully processed by tracing each tuple in the tuples tree. Each topology has a "message timeout" associated with it. If Storm does not discover that the tuple is processed within the timeout period, then the tuple fails and retries after a period of time.

To take advantage of Storm's reliability capabilities, you must tell Storm if new edges in a tuple tree is being create D and tell Storm whenever you ' ve finished processing an individual tuple. These is done using the Outputcollector object, the bolts use to emit tuples. Anchoring is do in the emit method, and you declare so you ' re finished with a tuple using the Ack method.

to ensure the reliable processing power of storm, you must tell Storm when a new tuple is created in a tuple tree, and when each tuple is processed. These are all done using the Outputcollector object. is implicitly done in the emit method, you can use the ACK method to declare that the tuple is processed.

This is any explained in much more detail in guaranteeing message processing. Tasks

Each spout or bolt executes as many tasks across the cluster. Each task corresponds to one thread of execution, and stream groupings define how to send tuples from one set of the tasks to Another set of tasks. You set the parallelism-spout or bolt in the Setspout and Setbolt methods of Topologybuilder.

spout or bolts run as multiple tasks in the cluster. Each task is a thread, and stream grouping determines how the tuples is sent from one task collection to another. You can use Topologybuilder's setspout and Setbolt to set up parallel processing for each spout or bolt. Workers

Topologies execute across one or more worker processes. Each worker process is a physical JVM and executes a subset of the "All" for the topology. For example, if the combined parallelism of the topology was and workers are allocated, then each worker would execut E 6 tasks (as threads within the worker). Storm tries to spread the tasks evenly across all the workers.

The topology is run in one or more worker. Each worker is a separate JVM that can handle a subset of all the tasks. For example: The parallelism set in topology is 300 and the assigned workers is 50, so each worker runs 6 tasks. Storm will distribute the task evenly for each worker.

Resources: config.topology_workers: This Config sets the number of WORKERS to allocate for executing the topology


Reference Link: http://storm.apache.org/documentation/Concepts.html

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.