gpt4 book ai didi

java - Oozie Java API Kerberos 身份验证

转载 作者:可可西里 更新时间:2023-11-01 14:45:57 36 4
gpt4 key购买 nike

我正在尝试使用 oozie java API 获取 oozie 作业状态。目前它失败并显示消息线程“main”中的异常 HTTP 错误代码:401:未经授权

我们在集群中使用 kerberos 身份验证和 key 表文件。请指导如何继续实现身份验证。

我目前的计划是:

import org.apache.oozie.client.OozieClient;

public class oozieCheck
{
public static void main(String[] args)
{

// get a OozieClient for local Oozie
OozieClient wc = new OozieClient(
"http://myserver:11000/oozie");

System.out.println(wc.getJobInfo(args[1]));

}
}

最佳答案

我想出了一种在我的 java api 中使用 kerberos 的方法。

首先获取kerberos tgt。

然后下面的代码就可以工作了:

import java.io.BufferedReader;
import java.io.FileReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.oozie.client.AuthOozieClient;
import org.apache.oozie.client.WorkflowJob.Status;

public class Wrapper
{
public static AuthOozieClient wc = null;
public static String OOZIE_SERVER_URL="http://localhost:11000/oozie";

public Wrapper ( String oozieUrlStr ) throws MalformedURLException
{
URL oozieUrl = new URL(oozieUrlStr);
// get a OozieClient for local Oozie
wc = new AuthOozieClient(oozieUrl.toString());
}

public static void main ( String [] args )
{
String lineCommon;
String jobId = args[0]; // The first argument is the oozie jobid

try
{
Wrapper client = new Wrapper(OOZIE_SERVER_URL);
Properties conf = wc.createConfiguration();

if(wc != null)
{
// get status of jobid from CLA
try
{
while (wc.getJobInfo(jobId).getStatus() == Status.RUNNING)
{
logger.info("Workflow job running ...");
logger.info("Workflow job ID:["+jobId+"]");
}
if(wc.getJobInfo(jobId).getStatus() == Status.SUCCEEDED)
{
// print the final status of the workflow job
logger.info("Workflow job completed ...");
logger.info(wc.getJobInfo(jobId));
}
else
{
// print the final status of the workflow job
logger.info("Workflow job Failed ...");
logger.info(wc.getJobInfo(jobId));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
else
{
System.exit(9999);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

关于java - Oozie Java API Kerberos 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18311766/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com