简体   繁体   English

Apache NiFi 1.10:如何将python脚本作为处理器执行?

[英]Apache NiFi 1.10 : How to execute a python script as a processor?

In NiFi <= v1.9 I used the following NiFi setup:在 NiFi <= v1.9 中,我使用了以下 NiFi 设置: 在此处输入图片说明

GetTwitter generates a JSON for every tweet gathered and attached to it there used to be a ExecuteStreamCommand that has the following parameters: GetTwitter为收集到的每条推文生成一个 JSON 并附加到它,其中曾经有一个ExecuteStreamCommand ,它具有以下参数: 在此处输入图片说明

This would allow me to get the flowfile as input, and I could analyse the content and do something (in this specific case I would put the content on Elasticsearch) - You could reach the same result if you do something like this cat flowfile.json | python <scriptname>.py这将允许我获取流文件作为输入,并且我可以分析内容并执行某些操作(在这种特定情况下,我会将内容放在 Elasticsearch 上)-如果您执行类似cat flowfile.json | python <scriptname>.py相同的结果cat flowfile.json | python <scriptname>.py cat flowfile.json | python <scriptname>.py

But now in >= v1.10 it seems I cannot do the same.但是现在在 >= v1.10 中似乎我不能这样做。 it gives me some error about parameters (it seems it wants to use the flowfile as parameter on calling the command/script instead, as it used to be, pass the flowfile as input. It gives me the following error:它给了我一些关于参数的错误(它似乎想在调用命令/脚本时使用流文件作为参数,就像以前一样,将流文件作为输入传递。它给了我以下错误: 错误

2019-12-16 14:28:44,953 ERROR [Timer-Driven Process Thread-2] o.a.n.p.standard.ExecuteStreamCommand ExecuteStreamCommand[id=ef1d15fb-016e-1000-3050-35fba1733f97] Transferring flow file StandardFlowFileRecord[uuid=c485d8aa-58e9-428c-84b1-b4acbd6275a7,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1576505352573-22, container=default, section=22], offset=663999, length=-1],offset=0,name=242802f9-5ffb-4a2c-90a5-27736459dfd0.json,size=0] to nonzero status. Executable command bash ended in an error: bash: line 1: $'{delete:status:id:1005156317567188992}\r': command not found
2019-12-16 14:28:44,962 ERROR [Timer-Driven Process Thread-2] o.a.n.p.standard.ExecuteStreamCommand ExecuteStreamCommand[id=ef1d15fb-016e-1000-3050-35fba1733f97] Transferring flow file StandardFlowFileRecord[uuid=5b617840-ba8e-47b3-9a27-06e8ec0f88bd,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1576505352573-22, container=default, section=22], offset=663999, length=-1],offset=0,name=eb9e236a-1ccb-4243-aa1c-e5de43746f80.json,size=0] to nonzero status. Executable command bash ended in an error: bash: line 1: $'{delete:status:id:1139832600422277120}\r': command not found

It seems it takes the flowfile JSON as parameter instead of input .似乎它将流文件 JSON 作为参数而不是 input 。 Any ideas?有任何想法吗?

well, This is not really a problem with NiFi per se: NiFi was installed with docker so I kept using the docker host as it was the correct machine.好吧,这并不是 NiFi 本身的问题:NiFi 是随 docker 一起安装的,所以我一直使用 docker 主机,因为它是正确的机器。

Embarassing.. :)尴尬.. :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM