2017-04-19 155 views
0

這是我嘗試運行的基本wordcount拓撲。但我收到錯誤爲'INFO org.apache.storm.zookeeper.server.SessionTrackerImpl - SessionTrackerImpl exited loop!'。誰能幫我這個??在Apache風暴中提交字數拓撲時出錯

當我刪除cluster.shutdown(),推文連續不斷地來,直到我按下Ctrl + 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

10秒(10000毫秒)可能沒有足夠的時間用於Twitter的連接建立和鳴叫進入你的拓撲結構。您應該將睡眠呼叫設置爲更長的時間(至少幾個小手指)。

至於顯示的工作計數,你的HashTagCounter螺栓打印出粗壯的計數?如果是這樣,打印輸出可能會在Storm的日誌消息中丟失。嘗試設置config.setDebud(false)(以減少日誌消息,並讓您有機會看到計數)或重寫HashTagCounter以將消息發送到與您正在運行Storm的控制檯分開的另一位置(消息代理,本地套接字接收器等)。