Oozie协调员一周中有一天



我正在尝试在Oozie工作流中创建一个条件,其中操作应该只在星期一执行(在工作流结束时(。

到目前为止,我在工作流中添加了一个决策节点,并在协调器中添加了当前日期作为参数,我需要测试一周中的哪一天。

coordinator.xml

<coordinator-app name="${project}_coord" frequency="${coord_frequency}" start="${coord_start_date}" end="${coord_end_date}" timezone="UTC" xmlns="uri:oozie:coordinator:0.1">
<controls>
<concurrency>1</concurrency>
<execution>LAST_ONLY</execution>
</controls>
<action>
<workflow>
<app-path>${wf_application_path}</app-path>
<configuration>
<property>
<name>currentDate</name>
<value>${coord:formatTime(coord:dateOffset(coord:nominalTime(), 0, ‘DAY’), “yyyyMMdd”)}</value>
</property>
</configuration>
</workflow>
</action>

workflow.xml

<decision name = "send_on_monday">
<switch>
<case to = "send_file">
${currentDay} eq "MON"  <-------- test on day of the week
</case>
<default to = "sendSuccessEmail" />
</switch>
</decision>
<action name="send_file">
<ssh xmlns="uri:oozie:ssh-action:0.1">
<host>${remoteNode}</host>
<command>/pythonvenv</command>
<args>${fsProjectDir}/send_file.py</args>
</ssh>
<ok to="sendSuccessEmail"/>
<error to="sendTechnicalFailureEmail"/>
</action>

我没有找到关于如何使用EL功能获得一周中的哪一天的信息。感谢您的帮助。

我在决策节点中使用wf:actionData找到了一个解决方案

workflow.sh

<action name="getDayOfWeek">
<ssh xmlns="uri:oozie:ssh-action:0.1">
<host>${remoteNode}</host>
<command>${fsProjectDir}/scripts/dayOfWeek.sh</command>
<capture-output/>
</ssh>
<ok to="send_on_monday"/>
<error to="sendTechnicalFailureEmail"/>
</action>
<decision name="send_on_monday">
<switch>
<case to = "send_file">
${wf:actionData('getDayOfWeek')['day'] eq 'Mon'}
</case>
<default to = "sendSuccessEmail" />
</switch>
</decision>

dayOfWeek.sh

#!/bin/sh
DOW=$(date +"%a")
echo day=$DOW

最新更新