Oozie Workflow EL function timestamp() does not give seconds

北慕城南 提交于 2019-12-13 19:24:14

问题


I have the following Oozie workflow:

<workflow-app name="${workflow_name}" xmlns="uri:oozie:workflow:0.4">

    <global>
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <configuration>
            <property>
                <name>mapred.job.queue.name</name>
                <value>${launcherQueueName}</value>
            </property>
            <property>
                <name>mapred.queue.name</name>
                <value>${launcherQueueName}</value>
            </property>
        </configuration>
    </global>

    <start to="email-1" />

    <action name="email-1">
        <email xmlns="uri:oozie:email-action:0.1">
            <to>${toEmailList}</to>
            <cc>${ccEmailList}</cc>
            <subject>ts</subject>
            <body> 
                TIMESTAMP:  ${timestamp()}
            </body>
        </email>

        <ok to="mail-2" />
        <error to="kill-fail" />
    </action>

... 4 more actions for mail-2, mail-3 and mail-4

    <kill name="kill-fail">
        <message>${workflow_name} failed, error
            message[${wf:errorMessage(wf:lastErrorNode())}]
        </message>
    </kill>

    <end name="end" />
</workflow-app>

The emails that I get have the timestamp values as

TIMESTAMP:  2016-01-27T16:19Z

Accoring to the EL definition, it should be in this format: (YYYY-MM-DDThh:mm:ss.sZ

Why am I not getting the seconds?

What I am actually trying to do: I am trying to figure out if these four function calls will always return the same value or different values. I need something that does not change and so if timestamp() doesnt work for me, then I want to consider coordinator's NominalTime / ActualTime EL functions.

If we cant get the seconds in the timestamp, is there a way to pause each action so as to allow them to execute across a time range of more than one minute?

EDIT: Summarizing Answers below by Samson Scharfrichter:

1) Why are there no seconds in timestamp() ?

Previous versions had seconds but version 4.2 does not.

2) Is there a function which can give me seconds as well?

AFAIK No

3) How to use the same time value in all actions of a workflow?

Pass coord:nominalTime() as a property from coordinator and use it multiple times in actions.

4) How to make an action pause in a workflow?

Thre is no simple way. Use a java action - a jar with a simple class which does Thread.sleep()


回答1:


Quoting Oozie documentation for V4.2

4.2.2 Basic EL Functions

String timestamp()

It returns the current datetime in ISO8601 format, down to minutes (yyyy-MM-ddTHH:mmZ), in the Oozie's processing timezone, i.e. 1997-07-16T19:20Z

That seems pretty consistent with what you get.

You can format coord:nominalTime() down to the second if you wish, but in the Coordinator -- therefore you must stuff the result into a <configuration> property to forward it to the Workflow script.

And AFAIK coord:actualTime() refers to a non-deterministic time, in the past, when the Coordinator started to think about its next Workflow instance. I can't imagine what it can be used for.

By the way, I don't get "what [you] are actually trying to do" ; if all you want is generate unique IDs for your actions, you have many ways to do it without relying on the fact that Oozie is slow and will not execute multiple actions in the same second.



来源:https://stackoverflow.com/questions/35047044/oozie-workflow-el-function-timestamp-does-not-give-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!