如何在OOZIE工作流程中使用逻辑运算符 [英] how to use logical operators in OOZIE workflow
问题描述
我有一个oozie工作流程 我正在使用决策控制节点 在谓词中我想&&"两种不同的条件 我需要使用&&"在它们之间获得最终的TRUE/FALSE结果
i have a oozie workflow im using decision control node in the predicate i want to "&&" two different conditions and i need to use "&&" in between them for the final TRUE/FALSE result
我找不到此类条件的谓词语法
i dont find the predicate syntax for such conditions
我正在使用
<decision name="comboDecision">
<switch>
<case to="alpha">
---------
</case>
</switch>
</decision>
我想这样做=
<decision name="comboDecision">
<switch>
<case to="alpha">
condition1 && condition2
</case>
</switch>
</decision>
有人可以在语法方面帮助我吗?
can anyone help me with the syntax ?
推荐答案
我将通过一个示例对此进行解释.
I will explain this with an example.
让我们假设我们有一个Java动作(我们将此动作称为getAgeInfo
),该动作会输出一个人的年龄:
Let's assume that we have a Java action (we will call this action as getAgeInfo
), which outputs age of a person:
'person.age': Age of the person
动作:
<action name='getAgeInfo'>
<!--Outputs 1 property: person.age: returns age of the person-->
<java>
..........
</java>
<ok to="makeClassification" />
<error to="fail" />
</action>
下一个动作是makeClassification
.
在makeClassification
行动中,我们根据人的年龄将其分为孩子",少年",中年人"或老年人".
The next action is makeClassification
.
In makeClassification
action, we classify a person into "child", "teenager", "mid-aged" or "senior-citizen", based on the person's age.
例如如果某人的年龄大于或等于(ge)12(并且)小于(lt)20,我们将该人分类为青少年,并且工作流程将转换为teenager
动作.
For e.g. if a person's age is greater than or equal to (ge) 12 (and) less than (lt) 20, we classify that person as a teenager and the workflow transitions to teenager
action.
下面是switch语句,它说明了"and"的使用:
Following is the switch statement, which illustrates use of "and":
<decision name="makeClassification">
<switch>
<case to="child">
${wf:actionData('getAgeInfo')['person.age'] gt 0 &&
wf:actionData('getAgeInfo')['person.age'] lt 12}
</case>
<case to="teenager">
${wf:actionData('getAgeInfo')['person.age'] ge 12 &&
wf:actionData('getAgeInfo')['person.age'] lt 20}
</case>
<case to="mid-aged">
${wf:actionData('getAgeInfo')['person.age'] ge 20 &&
wf:actionData('getAgeInfo')['person.age'] lt 50}
</case>
<case to="senior-citizen">
${wf:actionData('getAgeInfo')['person.age'] ge 50}
</case>
<default to="error"/>
</switch>
</decision>
您可以在此处看到另一个示例: Oozie by Example ,它说明了gt(大于),lt(小于),逻辑或(||),逻辑和(&&).
You can see another example here: Oozie by Example, which illustrates the use of gt (greater than), lt (less than), logical or (||), logical and (&&).
这篇关于如何在OOZIE工作流程中使用逻辑运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!