3

我是 java 新手,在使用 java 代码运行 oozie 作业时遇到了一些麻烦。我无法找出代码中的问题。一些帮助将不胜感激。这是我的代码

import java.util.Properties;

import org.apache.oozie.client.OozieClient;
import org.apache.oozie.client.WorkflowJob;

public class oozie {

public static void main(String[] args) {
    OozieClient wc = new OozieClient("http://host:11000/oozie");

    Properties conf = wc.createConfiguration();

    conf.setProperty(OozieClient.APP_PATH, "hdfs://cluster/user/apps/merge-psp-logs/merge-wf/workflow.xml");
    conf.setProperty("jobTracker", "jobtracker.bigdata.com:8021");
    conf.setProperty("nameNode", "hdfs://namenode.bigdata.com:8020");
    conf.setProperty("queueName", "jobtracker.bigdata.com:8021");
    conf.setProperty("appsRoot", "hdfs://namenode.bigdata.com:8020/user/workspace/apps");
    conf.setProperty("appLibLoc", "hdfs://namenode.bigdata.com:8020/user/workspace/lib");
    conf.setProperty("rawlogsLoc", "hdfs://namenode.bigdata.com:8020/user/workspace/");
    conf.setProperty("mergedlogsLoc", "jobtracker.bigdata.com:8021");
    try {
        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 (Exception r) {
        System.out.println("Errors");
    }
}
}

虽然我可以使用命令行启动作业

4

1 回答 1

2

如果没有任何进一步的信息,我会说这可能是您的运行时错误的原因:

conf.setProperty(OozieClient.APP_PATH, 
    "hdfs://cluster/user/apps/merge-psp-logs/merge-wf/workflow.xml");
conf.setProperty("jobTracker", "jobtracker.bigdata.com:8021");
conf.setProperty("nameNode", "hdfs://namenode.bigdata.com:8020");
conf.setProperty("queueName", "jobtracker.bigdata.com:8021");

除非您有两个集群,否则我的猜测是您的意思是 APP_PATH 指向与 nameNode 属性中命名的相同的 HDFS 实例,在这种情况下尝试:

conf.setProperty(OozieClient.APP_PATH, 
    "hdfs://namenode.bigdata.com:8020/user/apps/merge-psp-logs/merge-wf/workflow.xml");

您可能还想将 queueName 更改为真实的队列名称(可能是“默认”,除非jobtracker.bigdata.com:8021是队列的实际名称):

conf.setProperty("queueName", "default");

除了这些观察之外,请尝试发布您看到的实际运行时错误。

于 2012-10-11T10:31:53.873 回答