Oozie 协调器获取星期几

Oozie coordinator get day of the week

我正在尝试在我的 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