您好,登錄后才能下訂單哦!
Storm學習的HelloWorld
1、下載Storm-start(https://github.com/nathanmarz/storm-starter/archive/master.zip)
2、進入下載目錄,對zip文件解壓
3、進入解壓后的文件目錄,修改m2-pom.xml(將twitter4j-core和twitter4j-stream替換為下面的部分)
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.2,)</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>[2.2,)</version>
</dependency>
4、編譯項目。轉到項目根目錄,使用mvn -f m2-pom.xml package 進行編譯
5、復制storm-starter目錄下的m2_pom.xml為pom.xml,放在與m2_pom.xml同一目錄下
6、打jar包mvn jar:jar
如果還需要對工程代碼進行修改可以導入eclipse
使用mvn eclipse:eclipse編譯成eclipse工程
eclipse import project
7、提交運行
拷貝jar包到Storm所在機器上
編譯無誤后,在Storm-starter中target目錄下
將storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar,拷貝到指定的目錄下面
8、執行命令:
./storm jar /usr/soft/stormrun/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.WordCountTopology test
不加test參數時,就會運行local形式,會將所有運行信息打印到控制臺上,將會看到storm運行的每一步打印信息。
5186 [Thread-26] INFO backtype.storm.daemon.executor - Processing received message source: spout:8, stream: default, id: {}, [four score and seven years ago] four score and seven years ago------------------- 5194 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [four] 5195 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [score] 5196 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [and] 5197 [Thread-22] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [and] 5198 [Thread-22] INFO backtype.storm.daemon.task - Emitting: count default [and, 1] 5198 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [seven] 5199 [Thread-20] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [four] 5200 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [years] 5201 [Thread-18] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [seven] 5201 [Thread-26] INFO backtype.storm.daemon.task - Emitting: split default [ago] 5201 [Thread-18] INFO backtype.storm.daemon.task - Emitting: count default [seven, 1] 5205 [Thread-20] INFO backtype.storm.daemon.task - Emitting: count default [four, 1] 5205 [Thread-20] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, [score] 5205 [Thread-20] INFO backtype.storm.daemon.task - Emitting: count default [score, 1]
9、查看UI http://ip:8080 (端口號默認為8080,可以修改,一般為9090)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。