try {
// start local Oozie
LocalOozie.start();
// get a OozieClient for local Oozie
OozieClient wc = LocalOozie.getClient();
// create a workflow job configuration and set the workflow application path
Properties conf = wc.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, appUri + File.separator + "workflow.xml");
conf.setProperty("mapreduce.jobtracker.kerberos.principal", "mapred/localhost@LOCALHOST");
conf.setProperty("dfs.namenode.kerberos.principal", "hdfs/localhost@LOCALHOST");
// load additional workflow job parameters from properties file
if (propertiesFile != null) {
conf.load(new FileInputStream(propertiesFile));
}
// submit and start the workflow job
String jobId = wc.run(conf);
Thread.sleep(1000);
System.out.println("Workflow job submitted");
// wait until the workflow job finishes printing the status every 10 seconds
while (wc.getJobInfo(jobId).getStatus() == WorkflowJob.Status.RUNNING) {
System.out.println("Workflow job running ...");
printWorkflowInfo(wc.getJobInfo(jobId));
Thread.sleep(10 * 1000);
}
// print the final status o the workflow job
System.out.println("Workflow job completed ...");
printWorkflowInfo(wc.getJobInfo(jobId));
return (wc.getJobInfo(jobId).getStatus() == WorkflowJob.Status.SUCCEEDED) ? 0 : -1;
}
catch (Exception ex) {
System.out.println();
System.out.println(ex.getMessage());
return -1;