[英]Oozie java action-retry option
我试图每1分钟重复一次Java操作,最多重试6次。 我尝试下面的代码。
**Workflow.xml**
<workflow-app name="FilePoller" xmlns="uri:oozie:workflow:0.4">
<start to="FilePoller"/>
<action name="FilePoller" retry-max="10" retry-interval="1">
<java>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<main-class>com.test.Utils</main-class>
<arg>${input1}</arg>
<arg>${inputDir}</arg>
<archive>lib/filepollingscheduler.jar#filepollingscheduler.jar</archive>
</java>
<ok to="end"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
**Java code snippet:**
Pattern pattern = Pattern.compile(inputFilePattern);
Matcher matcher = pattern.matcher(path.getName());
if (matcher.find()) {
System.out.println("Matches found");
System.exit(0);
} else {
System.out.println("No matches found");
System.exit(1);
}
如果没有找到匹配项,我想重试该操作。
任何帮助表示赞赏。
通常,即使System.exit()为0,也将导致操作失败。
http://archive.cloudera.com/cdh4/cdh/4/oozie/WorkflowFunctionalSpec.html#a3.2.7_Java_Action
找到匹配项或抛出异常时,应让main()完成。
public static void main(...) {
...
if(!matcher.find())
throw new MatchNotFoundException();
return;
}
我相信捕获输出和决策节点将对您有用。 您可以尝试一下。 我所做的工作与此类似,但并不完全符合您的要求。
一旦工作流程执行完毕,我们就应根据是否找到匹配项将输出捕获为{true或false}。 根据结果,可以决定是再次执行工作流程还是应该停止工作流程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.