这是我试图运行的基本wordcount拓扑。但我收到的错误是' INFO org.apache.storm.zookeeper.server.SessionTrackerImpl - SessionTrackerImpl退出循环!'。任何人都可以帮我解决这个问题吗?
当我删除cluster.shutdown()时,推文会不断出现,直到我按下cntrl + c。再次,wordcount没有显示##
import java.util.Arrays;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
public class TwitterHashtagStorm {
public static void main(String[] args) throws Exception {
String consumerKey = "************";
String consumerSecret = "***************";
String accessToken = "**********";
String accessTokenSecret = "***********";
String[] keyWords = {"apple"};
Config config = new Config();
config.setDebug(true);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("twitter-spout", new TwitterSampleSpout(consumerKey,
consumerSecret, accessToken, accessTokenSecret, keyWords));
builder.setBolt("twitter-hashtag-reader-bolt", new HashtagReaderBolt())
.shuffleGrouping("twitter-spout");
builder.setBolt("twitter-hashtag-counter-bolt",
new HashtagCounterBolt()).fieldsGrouping(
"twitter-hashtag-reader-bolt", new Fields("hashtag"));
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("TwitterHashtagStorm", config,
builder.createTopology());
Thread.sleep(10000);
cluster.shutdown();
}
}
答案 0 :(得分:0)
10秒(10000毫秒)可能不足以让Twitter连接建立并且推文进入您的拓扑。您应该将睡眠呼叫设置为更长的时间(至少几个小步骤)。
至于显示工作计数,你的HashTagCounter螺栓是否打印出粗壮的计数?如果是这样,可能会在Storm的日志消息中丢失打印输出。尝试设置config.setDebud(false)
(以减少日志消息并让您有机会查看计数)或重写HashTagCounter以将消息发送到另一个位置(消息代理,本地套接字接收器等),与您的控制台分开运行Storm来自。