launching an oozie job using java code
Question
i am trying to launch an oozie job using javacode but unable to do the same. the following code gives an exception "unhandled type oozieClientException" for a couple of lines like
String jobId = wc.run(conf);
i am new to java and am seeking for some help. here's my code:
OozieClient wc = new OozieClient("http://host.com:11000/oozie");
Properties conf = wc.createConfiguration();
conf.setProperty(....)
...
String jobId = wc.run(conf);
System.out.println("Workflow job submitted");
while (wc.getJobInfo(jobId).getStatus() == WorkflowJob.Status.RUNNING) {
System.out.println("Workflow job running ...");
Thread.sleep(10 * 1000);
}
System.out.println("Workflow job completed ...");
System.out.println(wc.getJobInfo(jobId));
Solution
You should close code in the try catch block
try{
OozieClient wc = new OozieClient("http://host.com:11000/oozie");
Properties conf = wc.createConfiguration();
conf.setProperty(....)
...
String jobId = wc.run(conf);
System.out.println("Workflow job submitted");
while (wc.getJobInfo(jobId).getStatus() == WorkflowJob.Status.RUNNING) {
System.out.println("Workflow job running ...");
Thread.sleep(10 * 1000);
}
System.out.println("Workflow job completed ...");
System.out.println(wc.getJobInfo(jobId));
}catch(OozieClientException oozieClientException){
oozieClientException.printStackTrace();
}
OozieClientException - thrown if the job could not be submitted
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow