Apache NiFi 中的 GetFile 处理器持续 运行

GetFile processor continually running in Apache NiFi

我正在使用 Apache NiFi 将一些本地文件复制到 HDFS。 我创建了一个绑定到 PutHDFS 处理器的 GetFile 处理器。 GetFile 处理器递归查询 只读 目录。我遇到的问题是文件不断被复制,比如我删除了HDFS上复制的文件,然后它们很快又出现了。

GetFile 处理器配置中,我将 Keep Source File 设置为 true 因为该目录是只读的并且在 documentation 在只读目录中,如果此参数设置为 false,则文件将被忽略:

If true, the file is not deleted after it has been copied to the Content Repository; this causes the file to be picked up continually and is useful for testing purposes. If not keeping original NiFi will need write permissions on the directory it is pulling from otherwise it will ignore the file.

是否可以简单地将每个文件复制一次?

您可以使用 ListFile and FetchFile 处理器来执行此操作。 ListFile 将跟踪到目前为止它看到了哪些文件,除非它们被修改,否则不会继续列出它们。确保将 FetchFile 中的 Completion Strategy 设置为 "None",以确保不会尝试 move/delete 文件。