Storm运维:关于nextTuple

http://www.cnblogs.com/panfeng412/p/storm-spout-common-issues.html

http://blog.itpub.net/29754888/viewspace-1260026/

 

早上发现storm有点问题,查看日志,发现

2015-10-31T20:02:23.332+0800 STDIO [ERROR] java.lang.InterruptedException
2015-10-31T20:02:23.333+0800 STDIO [ERROR] at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014)
2015-10-31T20:02:23.333+0800 STDIO [ERROR] at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2048)
2015-10-31T20:02:23.333+0800 STDIO [ERROR] at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
2015-10-31T20:02:23.333+0800 STDIO [ERROR] at com.hzw.monitor.storm.spout.ActiveMQSpout.nextTuple(ActiveMQSpout.java:45)
2015-10-31T20:02:23.333+0800 STDIO [ERROR] at backtype.storm.daemon.executor$fn__6579$fn__6594$fn__6623.invoke(executor.clj:565)
2015-10-31T20:02:23.334+0800 STDIO [ERROR] at backtype.storm.util$async_loop$fn__459.invoke(util.clj:463)
2015-10-31T20:02:23.334+0800 STDIO [ERROR] at clojure.lang.AFn.run(AFn.java:24)
2015-10-31T20:02:23.334+0800 STDIO [ERROR] at java.lang.Thread.run(Thread.java:745)

然后定位,就是看nextTuple函数。

我们用的是一个LinkedBlockingQueue,用了take,这个函数

 Message java.util.concurrent.LinkedBlockingQueue.take() throws InterruptedException

Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.Specified by: take() in BlockingQueueReturns:the head of this queueThrows:InterruptedException - if interrupted while waiting

这个函数会阻塞当前线程。

 

然后nextTuple函数

 /**

     * When this method is called, Storm is requesting that the Spout emit tuples to the 

     * output collector. This method should be non-blocking, so if the Spout has no tuples

     * to emit, this method should return. nextTuple, ack, and fail are all called in a tight

     * loop in a single thread in the spout task. When there are no tuples to emit, it is courteous

     * to have nextTuple sleep for a short amount of time (like a single millisecond)

     * so as not to waste too much CPU.

     */

    void nextTuple();

 

所以,也就是说,这里不应该用take来处理。

后来通过修改为poll(),如果拿出的消息为null,则睡眠10ms.

 

转载于:https://my.oschina.net/qiangzigege/blog/524727

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值