简体   繁体   English

从Java杀死Oozie工作流程

[英]Killing an Oozie workflow from java

So i've been playing around with the Oozie java api, all fine and dandy until i've hit the following problem. 所以我一直在玩Oozie Java api,一切都很好,很花俏,直到遇到以下问题为止。 While trying to run the following java code: 尝试运行以下Java代码时:

OozieClient oc = new OozieClient(OOZIE_URL);

Properties conf = oc.createConfiguration();

conf.setProperty(OozieClient.APP_PATH, PATH_TO_WF);


String jobId = oc.run(conf);

while(oc.getJobInfo(jobId).getStatus() == WorkflowJob.Status.PREP){
    Thread.sleep(1000);
}

oc.kill(jobId);

This fails with the following exception: 此操作失败,但有以下异常:

E0508: User [?] not authorized for WF job [JOB_ID_GOES_HERE]

I've been able to find some related issues on google, though the ones i noticed were only related to the command line oozie client. 我已经在Google上找到了一些相关问题,尽管我注意到的仅与命令行oozie客户端有关。

My main question is that considering you can run an Oozie workflow from java as another user by simply adding: 我的主要问题是考虑到您可以通过简单地添加以下内容以其他用户身份从Java运行Oozie工作流程:

conf.setProperty("user.name", "user123");

Is there something similar that can be done with killing a workflow ? 杀死工作流程是否可以完成类似的工作?

Use AuthOozieClient and set system user. 使用AuthOozieClient并设置系统用户。

OozieClient oc = new AuthOozieClient(OOZIE_URL);
System.setProperty("user.name", userName);
client.kill(jobId);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM