在eclipse中调试storm-starter程序

1)下载twitter4j :twitter4j-2.2.6.zip(http://pan.baidu.com/s/1bzSO3),并解压unzip twitter4j-2.2.6.zip
   下载storm-starter-master.zip( git clone git://github.com/nathanmarz/storm-starter.git

 

2)使用eclipse建立java project。追加twitter4j和storm的jar文件:

File-> New -> Java Project ->起项目名-> Next -> Libraries -> add External JARs...->追加twitter4j和storm的jar文件(twitter4j-{version}/lib/*.jar,storm-{version}/lib/*.jar,storm-{version}/storm-{version}.jar
-> Finsh

    
或者可以在建java 项目完成后添加twitter4j和storm的jar文件:

项目名-> 右键->properties->java build path->Libraries -> add External JARs->追加twitter4j和storm的jar文件


3)导入storm-starter

File -> Import -> General -> File System -> Next -> Browse(From directory) -> storm-starter/src/jvm/storm -> Browse(Info floder)  -> 项目名/src -> OK -> “storm” 和 “Create top-level folder”前打勾 -> Finish


4)把配置文件storm.yaml加载到项目的src下。

完成后eclipse中项目显示如下:
在eclipse中调试storm-starter程序_第1张图片

这样就可以点Run 运行 storm.starter.ExclamationTopology,结果如下:

在eclipse中调试storm-starter程序_第2张图片

但运行storm.starter.WordCountTopology程序会报如下错误:

2128 [Thread-22] ERROR backtype.storm.util  - Async loop died!
java.lang.RuntimeException : Error when launching multilang subprocess

                at backtype.storm.task.ShellBolt.prepare( ShellBolt.java:82)
                at backtype.storm.daemon.executor$fn__4050$fn__4059.invoke(executor.clj:610)
                at backtype.storm.util$async_loop$fn__465.invoke(util.clj:375)
                at clojure.lang.AFn.run( AFn.java:24)
                at java.lang.Thread.run( Thread.java:662)
Caused by: java.io.IOException: Cannot run program "python" (in directory "/tmp/add60cdb-20da-4f1e-a2ae-c14e0eafa200/supervisor/stormdist/word-count-1-1382945411/resources"): java.io.IOException: error=2, No such file or directory
                at java.lang.ProcessBuilder.start( ProcessBuilder.java:460)
                at backtype.storm.utils.ShellProcess.launch( ShellProcess.java:31)
                at backtype.storm.task.ShellBolt.prepare( ShellBolt.java:79)
                ... 4 more
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
                at java.lang.UNIXProcess.( UNIXProcess.java:148)
                at java.lang.ProcessImpl.start( ProcessImpl.java:65)
                at java.lang.ProcessBuilder.start( ProcessBuilder.java:453)
                ... 6 more
2130 [Thread-22] ERROR backtype.storm.daemon.executor  -
java.lang.RuntimeException : Error when launching multilang subprocess

                at backtype.storm.task.ShellBolt.prepare( ShellBolt.java:82)
                at backtype.storm.daemon.executor$fn__4050$fn__4059.invoke(executor.clj:610)
                at backtype.storm.util$async_loop$fn__465.invoke(util.clj:375)
                at clojure.lang.AFn.run( AFn.java:24)
                at java.lang.Thread.run( Thread.java:662)
Caused by: java.io.IOException: Cannot run program "python" (in directory "/tmp/add60cdb-20da-4f1e-a2ae-c14e0eafa200/supervisor/stormdist/word-count-1-1382945411/resources"): java.io.IOException: error=2, No such file or directory
                at java.lang.ProcessBuilder.start( ProcessBuilder.java:460)
                at backtype.storm.utils.ShellProcess.launch( ShellProcess.java:31)
                at backtype.storm.task.ShellBolt.prepare( ShellBolt.java:79)
                ... 4 more
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
                at java.lang.UNIXProcess.( UNIXProcess.java:148)
                at java.lang.ProcessImpl.start( ProcessImpl.java:65)
                at java.lang.ProcessBuilder.start( ProcessBuilder.java:453)
                ... 6 more

这是因为wordcount程序需要用到python脚本,解决方法如下


追加源文件storm-start/multilang/resources(python 文件word count用),右击src -> Import -> General -> File System -> Next -> Browse(From directory) -> storm-starter/multilang/resources -> Browse(Info floder)  -> 项目名-> OK -> “resources”和“Create top-level folder”前打勾 -> Finish,右击resources->Build Path
->Include

完成后eclipse中项目显示如下:

在eclipse中调试storm-starter程序_第3张图片

 
点Run执行storm.starter.WordCountTopology程序结果如下:

在eclipse中调试storm-starter程序_第4张图片

你可能感兴趣的:(cloud)