Oozie Custom EL功能oozie for coordinator

时间:2017-12-03 19:01:21

标签: oozie oozie-coordinator

我想创建一个我将在oozie协调器中使用的自定义el函数。我的自定义el函数工作正常,但是当我将已定义的oozie el函数作为参数传递给我的el函数时,它会抛出异常。

coordinator.xml

$ {coord:dateToEpoch(coord:nominalTime()," yyyy-MM-dd' T' hh:mmZ")见下面的例子

<datasets>
    <dataset name="input1" frequency="${inputDataSetFrequence}" initial-instance="${initialInstance}"
             timezone="${timezone}">
        <uri-template>${inputBasePath}/${useCaseName}/bintime=${coord:dateToEpoch(coord:nominalTime(),  "yyyy-MM-dd'T'hh:mmZ")}
        </uri-template>
        <done-flag></done-flag>
    </dataset>
</datasets>
<input-events>
    <data-in name="coordInput1" dataset="input1">
        <instance>${coord:current(0)}</instance>
    </data-in>
</input-events>

我以前测试过的配置

<property>
<name>oozie.service.ELService.ext.functions.coord-job-submit-nofuncs</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>

常量参数正在运行,但动态参数无效

工作电话

$ {coord:dateToEpoch(&#34; 2009-01-01T08:00UTC&#34;,&#34; yyyy-MM-dd&#39; T&#39; hh:mmZ&#34;)

异常电话

$ {coord:dateToEpoch(coord:nominalTime(),&#34; yyyy-MM-dd&#39; T&#39; hh:mmZ&#34;)

尝试使用所有这些属性

    <property>
<name>oozie.service.ELService.ext.functions.job-submit</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.workflow</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.wf-sla-submit</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-job-submit-freq</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-job-submit-data</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-job-submit-instances</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-sla-create</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-sla-submit</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-action-create</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-action-create-inst</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-action-start</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-job-wait-timeout</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.bundle-submit</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>
<property>
<name>oozie.service.ELService.ext.functions.coord-job-submit-initial-instance</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>

<property>
<name>oozie.service.ELService.ext.functions.coord-job-submit-nofuncs</name>
<value>coord:dateToEpoch=com.mobileum.oozie.MobileumELFunctions#dateToEpoch</value>
</property>

异常

Caused by: java.lang.Exception: Unable to evaluate :${inputBasePath}/${useCaseName}/bintime=${coord:dateToEpoch(coord:nominalTime(),  "yyyy-MM-dd'T'hh:mmZ")}:

    at org.apache.oozie.coord.CoordELFunctions.evalAndWrap(CoordELFunctions.java:743)
    at org.apache.oozie.command.coord.CoordSubmitXCommand.resolveTagContents(CoordSubmitXCommand.java:1002)
    ... 37 more
Caused by: javax.servlet.jsp.el.ELException: No function is mapped to the name "coord:nominalTime"
    at org.apache.commons.el.Logger.logError(Logger.java:481)
    at org.apache.commons.el.Logger.logError(Logger.java:498)
    at org.apache.commons.el.Logger.logError(Logger.java:525)
    at org.apache.commons.el.FunctionInvocation.evaluate(FunctionInvocation.java:150)
    at org.apache.commons.el.FunctionInvocation.evaluate(FunctionInvocation.java:163)
    at org.apache.commons.el.ExpressionString.evaluate(ExpressionString.java:114)
    at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:274)
    at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
    at org.apache.oozie.util.ELEvaluator.evaluate(ELEvaluator.java:204)
    at org.apache.oozie.coord.CoordELFunctions.evalAndWrap(CoordELFunctions.java:734)

1 个答案:

答案 0 :(得分:2)

并非所有Oozie EL结构都在uri-template中进行评估。有关详细信息,请参阅Synchronous Datasets部分。以下摘录自uri-template

  

uri-template:标识数据集的URI模板,可以是   解析为具体的URI以标识特定的数据集实例。   URI模板使用:

构造      

常量:请参阅下面允许的EL时间常数。例如:$ {YEAR} / $ {MONTH}。

     

变量:必须在协调器作业提交给协调器引擎时解析变量。它们通常提供作业参数(配置属性)。例如:$ {market} / $ {language}

以下EL常量可以在同步数据集URI模板中使用:

  • YEAR
  • HOUR
  • MINUTE

问题与您的自定义EL函数实现无关。因此,即使您使用了以下内容,也无法使用:

<uri-template>${inputBasePath}/${useCaseName}/bintime=${coord:nominalTime()}</uri-template>