2

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

我们在集群中使用带有密钥表文件的 kerberos 身份验证。请指导如何进行身份验证。

我目前的程序是:

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

    }
}
4

2 回答 2

4

我想出了一种在我的 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();
        }
    }
}
于 2013-08-27T10:41:39.357 回答
0

如果文档没有提到 Kerberos,您必须修补 oozie 客户端。

于 2013-08-19T20:25:56.830 回答