Storm(三) storm-starter

原文鏈接storm-starter

storm-starter就是Storm工程里邊一個專門用來學(xué)習(xí)使用Storm的模塊。

Getting started

Prerequisites

首先,在你的用戶PATH下,你要安裝有java和git,并且storm-starter中有兩個例子使用了Python and Ruby。
其次,確保你已經(jīng)下載了storm-starter的源碼。Git/GitHub的初學(xué)者可以參考:
$ git clone git://github.com/apache/storm.git && cd storm/examples/storm-starter

storm-starter overview

storm-starter包含了一系列例子。如果這是你首次使用Storm,請先查看以下topologies:
ExclamationTopology: 最基本的topology
WordCountTopology: 多語言版本的最基本的topology,其中一個bolt使用Python實(shí)現(xiàn)。
ReachTopology: 基于Storm的一個復(fù)雜DRPC的例子

在你熟悉這些topologies之后,可以看一看src/jvm/org/apache/storm/starter/目錄下的其他topopologies,例如RollingTopWords,可以學(xué)一些高級的實(shí)現(xiàn)。如果你想更多的了解Storm是如何工作的,請前去Storm project page。

Using storm-starter with Maven

Build and install Storm jars locally

如果你使用的是Storm的最新開發(fā)板,例如從git上clone了Storm,那么你必須先執(zhí)行一次build。否則你將會遇到錯誤提示: "Could not resolve dependencies for project org.apache.storm:storm-starter:<storm-version>-SNAPSHOT".

# Must be run from the top-level directory of the Storm code repository
$ mvn clean install -DskipTests=true

這個命令會在本地生成Storm并把jar文件安裝到你的 $HOME/.m2/repository/。當(dāng)你運(yùn)行Maven的命令生成和運(yùn)行storm-starter(后邊會介紹),Maven將能夠在本地Maven repository($HOME/.m2/repository)中找到相應(yīng)的Storm版本。

Packaging storm-starter for use on a Storm cluster

使用如下命令打包一個jar套件:
$ mvn package
這將打包你的代碼和依賴到一個"uberjar" (or "fat jar"),文件路徑在target/storm-starter-{version}.jar。
uberjar的文件名例子:target/storm-starter-0.9.3-incubating-SNAPSHOT.jar

你可以通過storm CLI工具提交(運(yùn)行)uberjar中的topology:

  • 例子1:
    本地模式下運(yùn)行ExclamationTopology
    storm jar target/storm-starter-*.jar org.apache.storm.starter.ExclamationTopology
  • 例子2:
    遠(yuǎn)程/集群模式下運(yùn)行RollingTopWords,使用名稱"production-topology"
    storm jar storm-starter-*.jar org.apache.storm.starter.RollingTopWords production-topology remote

多語言編寫的topologies也可以提交并運(yùn)行,比如WordCountTopology。

以本地或遠(yuǎn)程模式提交拓?fù)涞膶Ρ龋?/em>取決于拓?fù)渲械膶?shí)際代碼,對RollingTopWords來說,可以通過命令行參數(shù)來設(shè)置。不同于RollingTopWords,ExclamationTopology總是提交到遠(yuǎn)程集群(硬編碼在程序中)或者通過自定義配置文件來設(shè)置。 類似的,諸如拓?fù)涿Q等選項(xiàng) 也可能是用戶可配置或硬編碼的,所以請確認(rèn)你選擇的拓?fù)涫侨绾卧O(shè)置和配置的。

Running unit tests

mvn test

Using storm-starter with IntelliJ IDEA

Importing storm-starter as a project in IDEA

在IntelliJ IDEA中執(zhí)行如下步驟可以把storm-starter導(dǎo)入為一個新的工程。

  • Open File > Import Project... 導(dǎo)航到storm-starter目錄或者你的storm克隆的目錄(比如~/git/storm/examples/storm-starter)。
  • 選擇Import project from external model,選擇"Maven"并點(diǎn)擊Next。
  • 接下來,選中Import Maven projects automatically,其他選項(xiàng)默認(rèn),點(diǎn)擊Next。
  • 確保在profiles配置中選中intellij profile,這對于確保依賴正確設(shè)置很重要。
  • 在下一個屏幕中點(diǎn)擊Next。
  • 選擇JDK,下一步。
    建議使用JDK 7及以上版本。
    最好使用Oracle JDK而不是OpenJDK。
  • 現(xiàn)在可以設(shè)置工程的名字,默認(rèn)名字是"storm-starter"。點(diǎn)擊“Finish”
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,525評論 19 139
  • Spring Boot 參考指南 介紹 轉(zhuǎn)載自:https://www.gitbook.com/book/qbgb...
    毛宇鵬閱讀 47,261評論 6 342
  • 原文鏈接Storm Tutorial 本人原創(chuàng)翻譯,轉(zhuǎn)載請注明出處 這個教程內(nèi)容包含如何創(chuàng)建topologies及...
    quiterr閱讀 1,750評論 0 6
  • 背景 OpenShift是目前比較主流的基于Kubernetes的容器云解決方案,OpenShift在kubern...
    小白_18M閱讀 1,310評論 0 5
  • 大家是不是感覺到,現(xiàn)在的生活條件越來越好了,可是身體卻越來越差了?很多年輕人走上6樓都會累的上氣不接下氣,據(jù)我10...
    唯佰康劉巖閱讀 391評論 0 0

友情鏈接更多精彩內(nèi)容