查看Oozie示例和文檔,看起來您需要一個工作流程文件才能從Java代碼運行oozie作業。有沒有辦法直接從Java代碼提交作業,而不需要工作流程文件?是否有任何預先存在的方式通過Java代碼動態生成這些文件?是否有任何預先存在的工具可以使它們更容易生成?還是必須編寫完整的代碼才能生成文件?使用Java代碼生成Oozie工作流程
現狀
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);
這將是可取的,如果前者是impossibble另一種情況是:
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需要在HDFS中提供workflow.xml,這將使您的首選方法變得不可能。一種選擇是以編程方式生成XML文件,將其上傳到HDFS並將其傳遞給Oozie運行。 – LiMuBei 2015-02-13 09:15:08