如何将python螺栓集成到apachestorm的java拓扑中?

jutyujz0  于 2021-06-24  发布在  Storm
关注(0)|答案(1)|浏览(360)

我试图将一个简单的python螺栓集成到一个已经配置好的storm拓扑中,该拓扑是使用apachestorm和storm crawler sdk创建的。我是按照这里的指示做的
但我经常犯错误:

java.lang.Exception: Shell Process Exception: Traceback (most recent call last):
  File "D:\<PATH>\storm.py", line 217, in run
    tup = readTuple()
  File "D:\<PATH>\storm.py", line 74, in readTuple
    cmd = readCommand()
  File "D:\<PATH>\storm.py", line 67, in readCommand
    msg = readMsg()
  File "D:\<PATH>\storm.py", line 42, in readMsg
    return json_decode(msg[0:-1])
  File "D:\<PATH>\storm.py", line 30, in <lambda>
    json_decode = lambda x: json.loads(x)
  File "C:\Users\akumar\AppData\Local\Continuum\Anaconda2\lib\json\__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "C:\Users\akumar\AppData\Local\Continuum\Anaconda2\lib\json\decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\akumar\AppData\Local\Continuum\Anaconda2\lib\json\decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

    at org.apache.storm.task.ShellBolt.handleError(ShellBolt.java:227) [storm-core-1.2.1.jar:1.2.1]
    at org.apache.storm.task.ShellBolt.access$1100(ShellBolt.java:72) [storm-core-1.2.1.jar:1.2.1]
    at org.apache.storm.task.ShellBolt$BoltReaderRunnable.run(ShellBolt.java:348) [storm-core-1.2.1.jar:1.2.1]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
96398 [Thread-40] ERROR o.a.s.t.ShellBolt - Halting process: ShellBolt died. Command: [python, D:/<PATH>/ClassifyBolt.py], ProcessInfo pid:12708, name:classify exitCode:0, errorString: 
java.lang.RuntimeException: org.apache.storm.multilang.NoOutputException: Pipe to subprocess seems to be broken! No output read.
Serializer Exception:

    at org.apache.storm.utils.ShellProcess.readShellMsg(ShellProcess.java:127) ~[storm-core-1.2.1.jar:1.2.1]
    at org.apache.storm.task.ShellBolt$BoltReaderRunnable.run(ShellBolt.java:330) [storm-core-1.2.1.jar:1.2.1]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
96399 [Thread-40] ERROR o.a.s.d.executor - 
java.lang.RuntimeException: org.apache.storm.multilang.NoOutputException: Pipe to subprocess seems to be broken! No output read.
Serializer Exception:

    at org.apache.storm.utils.ShellProcess.readShellMsg(ShellProcess.java:127) ~[storm-core-1.2.1.jar:1.2.1]
    at org.apache.storm.task.ShellBolt$BoltReaderRunnable.run(ShellBolt.java:330) [storm-core-1.2.1.jar:1.2.1]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]

我试图在storm crawler网站的示例爬虫示例提供程序中添加创建的螺栓。在我看来,pythonbolt似乎没有从拓扑中的前一个组件获取流。
有人能帮忙吗?

jucafojl

jucafojl1#

这可能是由于bolt的python进程将一些日志输出输出到stdout。默认情况下,multilang风暴螺栓使用进程的stdin/stdout与java进程通信。
使用pystorm作为pythonbolt基础设施将允许您使用不同的流进行通信,例如unix命名管道或套接字,并释放stdout用于常规日志记录。

相关问题