Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the relevant knowledge points of Spout

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the relevant knowledge points of Spout". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "what are the relevant knowledge points of Spout"!

Component

In Storm, Spout and Bolt are both its Compents, so in Storm, an IComponent is defined.

Total interface

Spout

In the previous basic example, we implemented a RandomSout, so let's look at its class diagram

The top-level abstraction of Spout is the ISpout interface

API related to

1: oepn method is initialization action: allows you to do some actions during the initialization of the spout, passing in the text, but also convenient to marry some data in the context

2: The close method executes before the Spout is closed, but there is no guarantee that it will execute, Spout is run as a task, inside the worker,

Under cloud cluster, our supervisor will kill directly, so it may not allow, and in local mode, as long as it is not kill-9, if it is to send a stop command, it can guarantee the execution of close.

3 : Activate

4 :deactivate

5: nextTuple : nextTuple is used to send data

6 ack ( Object ) : Ack The Object passed in is actually an id. It is the only tuple.

7 fail ( Object )

Because BaseRichSpout is inherited, there is no need to implement close, activate, deactivate, ack, fail

and so on.

Conclusion:

Under normal circumstances (except for Shel and Thing), implementing a Spout can directly implement IRichSpout

If you don't want to write IRIchSpout code, you can inherit from BaseRichSpout

Bolt

Class diagram of ExclaimBasicBolt

Ibolt inherits java.io.Serializable We submitted topology on nimbus

execute accepts a tuple for processing and feeds back the result of the processing in the ACK method passed in the prepare method, or the fail method

In general, it is equivalent to automatically doing away with the prepare method and collector.emit.ack(inputTupe).

At this point, I believe everyone has a deeper understanding of "what are the relevant knowledge points of Spout". You may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report