运行拓扑时,我在NullPointerException
方法中获取backtype.storm.utils.DisruptorQueue.consumeBatchToCursor
,特别是在螺栓中。 Spouts正式执行。
Storm的故障排除page表示可能是由于多个线程在OutputCollector上发布方法。但是,我看不出它与我的情况有什么关系。
这是鲸鱼喷水的代码:
(defspout stub-spout ["stub-spout"]
[conf context collector]
(spout
(nextTuple []
(let [channel-value (<!! storm-async-channel)]
(emit-spout! collector [channel-value])))
(ack [id]
))))
和螺栓:
(defbolt stub-bolt ["stub-bolt"] [tuple collector]
(println "Invocation!")
(let [obj (get tuple "object")
do-some-calculations (resolve 'calclib/do-some-calculations)
new-obj (do-some-calculations obj)]
(emit-bolt! collector new-obj)))
经过一番调查后发现,对resolve
的调用返回null(我需要resolve
在运行时,因为某些计算发生在位于calclib
的宏中。
但代码在本地群集中正常运行。为什么会这样?
对任何建议都会感激不尽。 谢谢!
答案 0 :(得分:1)
我想我已经找到了解决方案。螺栓定义更改为准备好的螺栓:
(defbolt stub-bolt ["stub-bolt"]
{:prepare true}
[conf context collector]
(let [f (load "/calclib/core")
do-some-calculations (resolve 'calclib/do-some-calculations)]
(bolt
(execute [tuple]
(let [obj (get tuple "object")
new-obj (do-some-calculations obj)]
(emit-bolt! collector new-obj))))))
键是对load
的调用。我不知道是否有更优雅的方法。