如何在 NiFi 中使用计数器的值
How to use value of a counter in NiFi
在 NiFi 1.3.0 中,我创建了一个流程来拆分 JSON 文件并使用名称 filenamecounter
更新计数器,以便我可以将每个拆分保存到不同的文件名中。当我查看 NiFi 计数器窗格时,我看到计数器值得到更新。但是我怎样才能访问这个值呢?
我尝试使用计数器名称和计数器 属性 设置属性。喜欢 ${filenamecounter}
和 ${filenamecounter.counter}
但不成功。
目前计数器主要是一种监控功能,您无法真正从表达式语言中访问它们。它们用于回答诸如 "how many messages have I received from source xyz?".
之类的问题
在您的情况下,所有 "split" 处理器都应该编写一组标准的片段属性:
@WritesAttribute(attribute = "fragment.identifier",
description = "All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute"),
@WritesAttribute(attribute = "fragment.index",
description = "A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile"),
@WritesAttribute(attribute = "fragment.count",
description = "The number of split FlowFiles generated from the parent FlowFile"),
因此您应该可以在文件名中使用 ${fragment.index}。
在 NiFi 1.3.0 中,我创建了一个流程来拆分 JSON 文件并使用名称 filenamecounter
更新计数器,以便我可以将每个拆分保存到不同的文件名中。当我查看 NiFi 计数器窗格时,我看到计数器值得到更新。但是我怎样才能访问这个值呢?
我尝试使用计数器名称和计数器 属性 设置属性。喜欢 ${filenamecounter}
和 ${filenamecounter.counter}
但不成功。
目前计数器主要是一种监控功能,您无法真正从表达式语言中访问它们。它们用于回答诸如 "how many messages have I received from source xyz?".
之类的问题在您的情况下,所有 "split" 处理器都应该编写一组标准的片段属性:
@WritesAttribute(attribute = "fragment.identifier",
description = "All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute"),
@WritesAttribute(attribute = "fragment.index",
description = "A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile"),
@WritesAttribute(attribute = "fragment.count",
description = "The number of split FlowFiles generated from the parent FlowFile"),
因此您应该可以在文件名中使用 ${fragment.index}。