Nifi:如何编写自定义处理器 [英] Nifi: how to write Custom processor

查看:700
本文介绍了Nifi:如何编写自定义处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个 nifi处理器,该处理器可以从hdfs目录中读取xml文件,然后将其数据提取到flowfile属性中,如果某些情况下,两个nifi处理器可以获取此文件并读取数据,或者在其中写入内容我如何进行文件锁定,以便一次只能有一个处理器使用它?您能向我推荐任何对我有帮助的文章,代码示例或一些相关材料吗?我还没有编写任何自定义处理器.

I want to write nifi processor which can read xml file from hdfs directory and then extracting it's data into flowfile attributes, also if there is case when two nifi processor can get this file and read data or write something into it how can i do file lock so that at a time only one processor can use it? Can you reccomend me any article, code examples or some related materials which can help me. i'haven't write any custom processor yet.

推荐答案

在这种情况下,我不确定为什么需要编写自定义处理器,因为GetHDFSEvaluateXPath处理器都存在并且应该能够在这里执行必要的任务.

I'm not sure why you need to write a custom processor in this case, because both GetHDFS and EvaluateXPath processors exist and should be able to perform the necessary tasks here.

在将流文件内容提取到属性中时要小心,因为流文件内容存储在内容存储库中,并且在流文件在流中移动时仅传递参考指针.但是,属性以内联方式存储在流文件存储库中,并占用堆空间以进行快速检索.如果不小心的话,很容易摄取大量的源数据,并意外地将整个数据块放入堆中.有关更多详细信息,请参见 Apache NiFi深入 .

Be careful when extracting flowfile content into attributes, as flowfile content is stored in the content repository and only a reference pointer is passed around as the flowfile moves through the flow. Attributes, however, are stored inline in the flowfile repository, and occupy heap space for rapid retrieval. It is easy to ingest a large piece of source data and accidentally put the whole block of data into the heap if you are not careful. See Apache NiFi In Depth for more details.

如果您仍然对执行自定义处理器开发感兴趣,请 Apache NiFi开发人员指南是另一本.最后,《 Apache NiFi贡献者指南》 包含checkstyle指示以及配置提示您的开发环境等

If you are still interested in performing custom processor development, this article by Bryan Bende is a good starting point. The versions referenced are stale, but the process described should hold up quite well. The Apache NiFi Developer Guide is another. Finally, the Apache NiFi Contributor Guide has checkstyle instructions, tips for configuring your development environment, etc.

这篇关于Nifi:如何编写自定义处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆