使用Java代码生成Oozie工作流
作者:互联网
通过Oozie示例和文档,您可能需要一个工作流文件才能从Java代码运行oozie作业.是否可以直接从Java代码提交作业,而无需工作流文件?是否存在通过Java代码动态生成这些文件的预先存在的方法?是否有任何预先存在的工具可以使它们更容易生成?或者我是否必须编写完整的代码来生成文件?
现在的情况
OozieClient wc = new OozieClient("http://bar:8080/oozie");
Properties conf = wc.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, "workflow file path");
// set other properties
...
// submit and start the workflow job
wc.run(conf);
理想的情况是模糊的.
OozieAction action = new OozieAction("actionName");
action.setOkDestination("nextAction");
action.setErrorDestination("errorDestination");
//Rest of config for action
OozieWorkflow workflow = new Oozieworkflow();
workfow.setStartAction(action);
workflow.addAction(otherAction);
//rest of conf
OozieClient wc = new OozieClient("http://bar:8080/oozie");
wc.runWorkflow(workflow);
如果前者不可能,那么另一种情况是可取的:
OozieAction action = new OozieAction("actionName");
action.setOkDestination("nextAction");
action.setErrorDestination("errorDestination");
//Rest of config for action
OozieWorkflow workflow = new Oozieworkflow();
workfow.setStartAction(action);
workflow.addAction(otherAction);
//rest of conf
workflow.writeToFile("some localFile")
//load file to HDFS
//This would also work
// workflow.writeToHDFS("someHdfsLocation");
OozieClient wc = new OozieClient("http://bar:8080/oozie");
//run with created workflow
解决方法:
我一直处于类似的情况.
我建议使用oozie模式定义(xsd)并通过xjc生成java等效对象.鉴于这些对象,您可以创建工作流程(尽管不是很简单)
您可以使用基于scala的DSL
https://github.com/klout/scoozie与Scala-> oozie代相似
标签:java,oozie 来源: https://codeday.me/bug/20190624/1275656.html