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

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

问题描述

我想编写 nifi 处理器,它可以从 hdfs 目录读取 xml 文件,然后将其数据提取到流文件属性中,如果有两个 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 In Depth.

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.

如果您仍然对执行自定义处理器开发感兴趣,请Bryan Bende 的这篇文章 是一个很好的起点.引用的版本是陈旧的,但所描述的过程应该很好.Apache NiFi 开发人员指南 是另一个.最后,Apache NiFi Contributor Guide 有 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天全站免登陆