使用java代码启动oozie作业

mepcadol  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(380)

我正在尝试使用javacode启动一个oozie作业,但是做不到。下面的代码给出了一个异常“unhandled type oozieclientexception”,其中有几行是这样的

String jobId = wc.run(conf);

我是java新手,正在寻求帮助。这是我的密码:

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));
b1payxdu

b1payxdu1#

您应该关闭try catch块中的代码

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-如果无法提交作业,则引发

相关问题