最近,我开始研究storm,对python更加熟悉,我决定使用streamparse来处理storm。我计划在spoute中接受twitter流,并在bolt中执行一些计算。但我不知道我该如何在spoute中编码。我看过各种streamparse教程,但它们都显示了静态列表中的喷口发射元组,并且没有类似twitter流式api提供的流。 这是我的暴风密码:
class WordSpout(Spout):
def initialize(self, stormconf, context):
self.words = itertools.cycle(['dog', 'cat','zebra', 'elephant'])
def next_tuple(self):
word = next(self.words)
self.emit([word])
这是我的tweepy代码:
^{pr2}$我应该如何集成这两个代码?在
为此,我设置了一个kafka队列,tweepy侦听器通过这个队列编写状态.text使用pykafka进入队列。然后喷口不断地从队列中读取数据来执行分析。我的代码看起来有点像这样:
在listener.py公司名称:
喷口文件:
^{pr2}$相关问题 更多 >
编程相关推荐