nifi 检查:属性值匹配
nifi check: attribute value match
我正在尝试在更新属性处理器中编写 EL。以下是我的要求:
用户输入:IP地址
存储在属性中:target.host.name.linux
我在 nifi.properties 中定义了另一组属性:
trigger.target.system.linux.name=10.44.245.33
trigger.target.system.linux.password=Passw0rd
我正在尝试将用户输入的值与属性文件中存在的属性值进行比较。如果它们匹配,我将在 true 条件下分配 trigger.target.system.linux.password
上方的变量,否则发布 'no match'
以下是我试过但没有成功的一些 EL:
${${target.host.name.linux:equals(${trigger.target.system.linux.name})}:ifElse(${trigger.target.system.linux.password},'no match')}
${${'target.host.name.linux':equals(${'trigger.target.system.linux.name'})}:ifElse(${'trigger.target.system.linux.password'},'no match')}
${${${target.host.name.linux}:equals(${trigger.target.system.linux.name})}:ifElse(${trigger.target.system.linux.password},'no match')}
有什么想法吗?
您可以在 UpdateAttribute 处理器中使用此 EL:
Key: target.host.name.linux
Value: ${target.host.name.linux:equals(${trigger.target.system.linux.name}):ifElse(${trigger.target.system.linux.password},'no-match')}
插图:
属性文件中的条目
检查EL的测试流程
更新属性处理器
用户输入匹配值(用户输入步骤)
UpdateAttribute EL 结果
用户输入了不匹配的值(用户输入步骤)
UpdateAttribute EL 结果
nifi.properties
文件不是自定义 属性 定义的好位置 -- 它被应用程序框架用于配置,但并非设计为接受任意值。
对于您的用例,您应该利用 Apache NiFi 的 Variable Registry 功能,它允许您定义自定义变量并在表达式语言子句中引用它们。在这种情况下,在注册表中定义两个变量,然后使用 RouteOnAttribute
处理器根据匹配路由到一个或另一个 UpdateAttribute
处理器(此方法删除嵌套的 EL ifElse
表达式; 如果您对它们感到满意,则可以坚持使用 Jagrut 建议的 UpdateAttribute
方法)。
我正在尝试在更新属性处理器中编写 EL。以下是我的要求:
用户输入:IP地址
存储在属性中:target.host.name.linux
我在 nifi.properties 中定义了另一组属性:
trigger.target.system.linux.name=10.44.245.33
trigger.target.system.linux.password=Passw0rd
我正在尝试将用户输入的值与属性文件中存在的属性值进行比较。如果它们匹配,我将在 true 条件下分配 trigger.target.system.linux.password
上方的变量,否则发布 'no match'
以下是我试过但没有成功的一些 EL:
${${target.host.name.linux:equals(${trigger.target.system.linux.name})}:ifElse(${trigger.target.system.linux.password},'no match')}
${${'target.host.name.linux':equals(${'trigger.target.system.linux.name'})}:ifElse(${'trigger.target.system.linux.password'},'no match')}
${${${target.host.name.linux}:equals(${trigger.target.system.linux.name})}:ifElse(${trigger.target.system.linux.password},'no match')}
有什么想法吗?
您可以在 UpdateAttribute 处理器中使用此 EL:
Key: target.host.name.linux
Value: ${target.host.name.linux:equals(${trigger.target.system.linux.name}):ifElse(${trigger.target.system.linux.password},'no-match')}
插图:
属性文件中的条目
检查EL的测试流程
更新属性处理器
用户输入匹配值(用户输入步骤)
UpdateAttribute EL 结果
用户输入了不匹配的值(用户输入步骤)
UpdateAttribute EL 结果
nifi.properties
文件不是自定义 属性 定义的好位置 -- 它被应用程序框架用于配置,但并非设计为接受任意值。
对于您的用例,您应该利用 Apache NiFi 的 Variable Registry 功能,它允许您定义自定义变量并在表达式语言子句中引用它们。在这种情况下,在注册表中定义两个变量,然后使用 RouteOnAttribute
处理器根据匹配路由到一个或另一个 UpdateAttribute
处理器(此方法删除嵌套的 EL ifElse
表达式; 如果您对它们感到满意,则可以坚持使用 Jagrut 建议的 UpdateAttribute
方法)。