Sample Code
Function
Oozie submits a job from the run method of org.apache.oozie.client.OozieClient and obtains job information from getJobInfo.
Sample Code
public void test() throws Exception
{
try
{
System.out.println("cluset status is " + isSecury);
if (isSecury)
{
UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>()
{
public Void run() throws Exception
{
runMapReduceJob();
return null;
}
});
}
else
{
runMapReduceJob();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void runMapReduceJob() throws OozieClientException, InterruptedException
{
String mrJobFilePath = userConfDir + JOB_PROPERTIES_FILE;
Properties conf = getJobProperties(mrJobFilePath);
// submit and start the workflow job
String jobId = wc.run(conf);
System.out.println("Workflow job submitted: " + jobId);
// 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 ..." + jobId);
Thread.sleep(10 * 1000);
}
// print the final status of the workflow job
System.out.println("Workflow job completed ..."+jobId);
System.out.println(wc.getJobInfo(jobId));
} Last Article: Description
Next Article: Scheduling Spark2x to Access HBase and Hive Using Oozie
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.