在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線(xiàn)課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Apache Storm是什么

汽車(chē)電子技術(shù) ? 來(lái)源:碼農(nóng)與軟件時(shí)代 ? 作者:碼農(nóng)與軟件時(shí)代 ? 2023-02-20 15:34 ? 次閱讀

一、概念

Apache Storm作為流數(shù)據(jù)的實(shí)時(shí)處理框架,官網(wǎng)給出了如下模型:

圖片

圖中“水龍頭”便是spout [spa?t] 出水管,“閃電”便是bolt [b??lt],“箭頭”表達(dá)的是數(shù)據(jù)的流轉(zhuǎn),“水龍頭”、“閃電”和“箭頭”組成的有向無(wú)環(huán)圖稱(chēng)為T(mén)opology(拓?fù)洌?/p>

使用Storm框架進(jìn)行流數(shù)據(jù)的實(shí)時(shí)處理,就需要編寫(xiě)“水龍頭”和“閃電”的處理邏輯,并將它們通過(guò)Topology串接在一起,構(gòu)建實(shí)時(shí)處理的業(yè)務(wù)邏輯。

具體的做法是:

(1)實(shí)時(shí)數(shù)據(jù)源,如kafka,接入到“水龍頭”Spout中;

(2)Spout讀取源數(shù)據(jù)并不斷地發(fā)出數(shù)據(jù)到后續(xù)Bolt中,這些數(shù)據(jù)稱(chēng)為T(mén)uple(元組);

(3)Bolt對(duì)發(fā)送過(guò)來(lái)的數(shù)據(jù)Tuple進(jìn)行處理,完成數(shù)據(jù)流轉(zhuǎn)換;

讀到這里,可能還是很迷惑,我們以常見(jiàn)的示例統(tǒng)計(jì)詞頻(heart.txt)來(lái)進(jìn)行說(shuō)明:

Take me to your heart
Take me to your soul
Give me your hand and hold me
Show me what love is
Be my guiding star
It's easy take me to your heart
Standing on a mountain high
Looking at the moon through a clear blue sky

我們可以設(shè)計(jì)一個(gè)topology:

WordSourceSpout:讀取heart.txt,并逐行發(fā)送數(shù)據(jù)流Stream,每行即為一個(gè)Tuple;
WordSplitBolt:拆分Tuple,并將單詞Tuple發(fā)出到下個(gè)Bolt;
WordCountBolt:對(duì)單詞的頻率進(jìn)行累加計(jì)算;

二、編程

1.Topology是如何構(gòu)建的?

Topology是通過(guò)TopologyBuilder來(lái)構(gòu)建的,提供setSpout和setBolt方法來(lái)配置Spout和Bolt,這兩個(gè)方法都具有3個(gè)參數(shù),比較類(lèi)似,以setSpout為例,第1個(gè)參數(shù)表示Stream的名稱(chēng),第2個(gè)參數(shù)表示stream的處理對(duì)象,第3個(gè)參數(shù)表示并發(fā)數(shù),也就是同時(shí)運(yùn)行多少個(gè)任務(wù)來(lái)處理Stream。先來(lái)看一段代碼:

TopologyBuilder topologyBuilder = new TopologyBuilder();
WordSourceSpout spout = new WordSourceSpout();
WordSplitBolt splitBlot = new WordSplitBolt();
WordCountBolt countBlot = new WordCountBolt();
topologyBuilder.setSpout("sentences", spout, 2);
topologyBuilder.setBolt("split",splitBlot , 8).shuffleGrouping("sentences");
topologyBuilder.setBolt("count",countBlot , 8).fieldGrouping("split",new Fields(“word”));

上面定義了兩個(gè)Bolt,它們之間數(shù)據(jù)流的關(guān)聯(lián)關(guān)系:第1個(gè)Bolt聲明其輸出Stream的名稱(chēng)為split,而第2個(gè)Bolt訂閱的Stream為split。countBlot 通過(guò)fieldGroupings()在word上具有相同字段的所有Tuple發(fā)送到同一個(gè)任務(wù)中進(jìn)行統(tǒng)計(jì)。

2.Spout和Bolt是如何定義的?

編程模型中,Spout和Bolt都稱(chēng)為組件Component。

WordSourceSpout 需要繼承BaseRichSpout,其類(lèi)結(jié)構(gòu)關(guān)系為:

BaseRichSpout--繼承--BaseComponent--實(shí)現(xiàn)--IComponent
BaseRichSpout--實(shí)現(xiàn)--IRichSpout--實(shí)現(xiàn)--ISpout

ISpout接口的定義為:

public interface ISpout extends Serializable {
    /**
     * Called when a task for this component is initialized within a worker on the cluster. It provides the spout with the environment in
     * which the spout executes.
     *
     * 

This includes the: * * @param conf The Storm configuration for this spout. This is the configuration provided to the topology merged in with cluster * configuration on this machine. * @param context This object can be used to get information about this task's place within the topology, including the task id and * component id of this task, input and output information, etc. * @param collector The collector is used to emit tuples from this spout. Tuples can be emitted at any time, including the open and * close methods. The collector is thread-safe and should be saved as an instance variable of this spout object. */ void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector); /** * Called when an ISpout is going to be shutdown. There is no guarentee that close will be called, because the supervisor kill -9's * worker processes on the cluster. * *

The one context where close is guaranteed to be called is a topology is killed when running Storm in local mode. */ void close(); /** * Called when a spout has been activated out of a deactivated mode. nextTuple will be called on this spout soon. A spout can become * activated after having been deactivated when the topology is manipulated using the `storm` client. */ void activate(); /** * Called when a spout has been deactivated. nextTuple will not be called while a spout is deactivated. The spout may or may not be * reactivated in the future. */ void deactivate(); /** * When this method is called, Storm is requesting that the Spout emit tuples to the output collector. This method should be * non-blocking, so if the Spout has no tuples to emit, this method should return. nextTuple, ack, and fail are all called in a tight * loop in a single thread in the spout task. When there are no tuples to emit, it is courteous to have nextTuple sleep for a short * amount of time (like a single millisecond) so as not to waste too much CPU. */ void nextTuple(); /** * Storm has determined that the tuple emitted by this spout with the msgId identifier has been fully processed. Typically, an * implementation of this method will take that message off the queue and prevent it from being replayed. */ void ack(Object msgId); /** * The tuple emitted by this spout with the msgId identifier has failed to be fully processed. Typically, an implementation of this * method will put that message back on the queue to be replayed at a later time. */ void fail(Object msgId); }

WordCountBolt需要繼承BaseBasicBolt,其類(lèi)結(jié)構(gòu)關(guān)系為:

BaseBasicBolt--繼承--BaseComponent--實(shí)現(xiàn)--IBasicBolt--IComponent

IBasicBolt接口的定義為:

public interface IBasicBolt extends IComponent {
    void prepare(Map topoConf, TopologyContext context);


    /**
     * Process the input tuple and optionally emit new tuples based on the input tuple.
     *
     * 

All acking is managed for you. Throw a FailedException if you want to fail the tuple. */ void execute(Tuple input, BasicOutputCollector collector); void cleanup(); }

IComponent接口的定義:

/**
 * Common methods for all possible components in a topology. This interface is used when defining topologies using the Java API.
 */
public interface IComponent extends Serializable {


    /**
     * Declare the output schema for all the streams of this topology.
     *
     * @param declarer this is used to declare output stream ids, output fields, and whether or not each output stream is a direct stream
     */
    void declareOutputFields(OutputFieldsDeclarer declarer);


    /**
     * Declare configuration specific to this component. Only a subset of the "topology.*" configs can be overridden. The component
     * configuration can be further overridden when constructing the topology using {@link TopologyBuilder}
     */
    Map<String, Object> getComponentConfiguration();


}

Storm框架基本邏輯為:

Spout組件通過(guò)Open方法進(jìn)行SpoutOutputCollector(Spout輸出收集器)的初始化,Storm調(diào)用Spout組件的nextTuple方法請(qǐng)求tuple時(shí),便通過(guò)SpoutOutputCollector的emit方法發(fā)送一個(gè)tuple。Bolt組件通過(guò)execute方法接收到tuple,并對(duì)tuple進(jìn)行數(shù)據(jù)處理。

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 邏輯
    +關(guān)注

    關(guān)注

    2

    文章

    834

    瀏覽量

    29634
  • 編寫(xiě)
    +關(guān)注

    關(guān)注

    0

    文章

    29

    瀏覽量

    8565
  • Storm框架
    +關(guān)注

    關(guān)注

    0

    文章

    3

    瀏覽量

    1582
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    Storm使用場(chǎng)景

    Storm基礎(chǔ)(一):架構(gòu)和組件
    發(fā)表于 06-11 16:37

    Storm高階之Trident的全面介紹

    Storm高階(一):Trident
    發(fā)表于 07-29 10:18

    雅虎機(jī)器學(xué)習(xí)平臺(tái)CaffeOnSpark解讀

    Andy Feng是Apache Storm的Committer,同時(shí)也是雅虎公司負(fù)責(zé)大數(shù)據(jù)與機(jī)器學(xué)習(xí)平臺(tái)的副總裁。他帶領(lǐng)雅虎機(jī)器學(xué)習(xí)團(tuán)隊(duì)基于開(kāi)源的Spark和Caffe開(kāi)發(fā)了深度學(xué)習(xí)框架
    發(fā)表于 10-10 11:46 ?0次下載
    雅虎機(jī)器學(xué)習(xí)平臺(tái)CaffeOnSpark解讀

    怎樣在Docker Swarm上部署Apache Storm

    本文是一篇來(lái)源于Baqend Tech博客的客座轉(zhuǎn)貼,描述了如何在Docker Swarm,而不是在虛擬機(jī)上部署和調(diào)配Apache Storm集群。這個(gè)題目很有意思,Wolfram
    發(fā)表于 10-10 14:24 ?0次下載
    怎樣在Docker Swarm上部署<b class='flag-5'>Apache</b> <b class='flag-5'>Storm</b>

    如何利用Storm完成實(shí)時(shí)分析處理數(shù)據(jù)

    Storm本身是Apache托管的開(kāi)源的分布式實(shí)時(shí)計(jì)算系統(tǒng),它的前身是Twitter Storm。在Storm問(wèn)世以前,處理海量的實(shí)時(shí)數(shù)據(jù)信息,大部分是類(lèi)似于使用消息隊(duì)列,加上工作進(jìn)程
    發(fā)表于 04-26 15:30 ?8200次閱讀
    如何利用<b class='flag-5'>Storm</b>完成實(shí)時(shí)分析處理數(shù)據(jù)

    Storm環(huán)境下基于權(quán)重的任務(wù)調(diào)度算法

    大數(shù)據(jù)流式計(jì)算平臺(tái)Apache Storm默認(rèn)采用輪詢(xún)的方式進(jìn)行任務(wù)調(diào)度,未考慮到拓?fù)渲懈魅蝿?wù)計(jì)算開(kāi)銷(xiāo)的差異以及任務(wù)之間不同類(lèi)型的通信模式,在負(fù)載均衡和通信開(kāi)銷(xiāo)方面存在較大的優(yōu)化空間。針對(duì)這一
    發(fā)表于 04-17 10:52 ?0次下載
    <b class='flag-5'>Storm</b>環(huán)境下基于權(quán)重的任務(wù)調(diào)度算法

    探討Apache kafka在部署可伸縮物聯(lián)網(wǎng)解決方案中所扮演的角色

    Apache stormApache spark和Apache hadoop集群提供支持的數(shù)據(jù)處理管道的網(wǎng)關(guān)。
    發(fā)表于 07-21 09:37 ?645次閱讀

    一種基于Apache Storm的增量式FFT方法

    針對(duì)傳統(tǒng)單機(jī)版批處理式的快速傅里葉變換( Fast fourier transfor,F(xiàn)FT)難以滿(mǎn)足工業(yè)生產(chǎn)現(xiàn)場(chǎng)海量流數(shù)據(jù)實(shí)時(shí)處理的需求,提出一種基于Δ pache Storm的增量式FFT方法
    發(fā)表于 04-28 14:44 ?10次下載
    一種基于<b class='flag-5'>Apache</b> <b class='flag-5'>Storm</b>的增量式FFT方法

    Apache與Weblogic的整合

    Apache與Weblogic的整合(電源技術(shù)論文錄用后可以改作者嗎)-Apache與Weblogic的整合? ? ? ? ? ? ? ? ? ? ? ?
    發(fā)表于 08-31 11:24 ?7次下載
    <b class='flag-5'>Apache</b>與Weblogic的整合

    Linux的apache

    Linux的apache(ups電源技術(shù)轉(zhuǎn)讓)-Linux的apache,有需要的可以參考!
    發(fā)表于 08-31 16:17 ?1次下載
    Linux的<b class='flag-5'>apache</b>

    Storm-Engine基于C++的開(kāi)源游戲引擎

    ./oschina_soft/storm-engine.zip
    發(fā)表于 06-16 10:05 ?0次下載
    <b class='flag-5'>Storm</b>-Engine基于C++的開(kāi)源游戲引擎

    Apache Doris正式成為 Apache 頂級(jí)項(xiàng)目

    全球最大的開(kāi)源軟件基金會(huì) Apache 軟件基金會(huì)(以下簡(jiǎn)稱(chēng) Apache)于美國(guó)時(shí)間 2022 年?6 月 16 日宣布,Apache Doris 成功從 Apache 孵化器畢業(yè),
    的頭像 發(fā)表于 06-17 14:08 ?1131次閱讀

    Apache Storm的安裝部署

    Storm是一個(gè)免費(fèi)開(kāi)源的分布式實(shí)時(shí)計(jì)算系統(tǒng)。分布式意味著Storm是一個(gè)集群,部署在多臺(tái)機(jī)器上。實(shí)時(shí)便是實(shí)時(shí)計(jì)算,相比于MapReduce的批處理,實(shí)時(shí)更關(guān)注于數(shù)據(jù)處理的速度和延時(shí)。
    的頭像 發(fā)表于 02-20 15:41 ?1130次閱讀
    <b class='flag-5'>Apache</b> <b class='flag-5'>Storm</b>的安裝部署

    大數(shù)據(jù)平臺(tái)有哪些 大數(shù)據(jù)技術(shù)應(yīng)用有哪些

    。   2. 實(shí)時(shí)數(shù)據(jù)處理平臺(tái):Apache Kafka、Apache StormApache Ignite等,專(zhuān)注于實(shí)時(shí)數(shù)據(jù)處理和流計(jì)算,適用于流媒體、監(jiān)控和物聯(lián)網(wǎng)等場(chǎng)景。
    的頭像 發(fā)表于 04-16 16:14 ?1.4w次閱讀

    什么是Apache日志?Apache日志分析工具介紹

    Apache Web 服務(wù)器在企業(yè)中廣泛用于托管其網(wǎng)站和 Web 應(yīng)用程序,Apache 服務(wù)器生成的原始日志提供有關(guān) Apache 服務(wù)器托管的網(wǎng)站如何處理用戶(hù)請(qǐng)求以及訪(fǎng)問(wèn)您的網(wǎng)站時(shí)經(jīng)常遇到的錯(cuò)誤的重要信息。
    的頭像 發(fā)表于 01-04 10:09 ?1026次閱讀
    主站蜘蛛池模板: 国产精品影视 | 久久精品国产四虎 | 不卡视频免费在线观看 | av福利网址网站 | 国产精品露脸脏话对白 | 天天躁夜夜躁狠狠躁 | 欧洲freexxxx性 | 久久黄网站 | 欧美性狂猛xxxxxbbbbb | 久久久夜| 在线五月婷婷 | videosxxoo18在线 | 天天插天天插 | 一区二区三区伦理 | 又污又黄的网站 | 久久观看 | 国产欧美精品一区二区色综合 | 222网站高清免费观看 | 国产黄在线观看 | 性做久久久久久网站 | 日本口工禁漫画无遮挡全彩 | 一级毛片一级毛片一级毛片 | 天天拍夜夜添久久精品免费 | 免费国产黄网站在线观看视频 | 欧美在线不卡视频 | 二级片在线| 激情综合丁香 | 夜间免费小视频 | 免费观看视频网站 | 黄 色 片免费观看 | 日本最黄 | 亚洲高清在线视频 | 欧美特黄一级视频 | 天天噜噜噜 | 色黄视频网站 | 日本sese | 九九99视频在线观看视频观看 | 一级毛片免费毛片一级毛片免费 | 小屁孩cao大人免费网站 | 国产午夜a理论毛片在线影院 | 免费黄色小视频 |