2013-08-19 3 views
2

oozie java API를 사용하여 oozie 작업 상태를 얻으려고합니다. 현재 메시지로 인해 실패했습니다. 스레드 "main"의 예외 HTTP 오류 코드 : 401 : UnauthorizedOozie Java API Kerberos 인증

keytab 파일과 함께 kerberos 인증을 사용하고 있습니다. 인증 구현 방법을 안내하십시오.

나의 현재 프로그램입니다 : 당신은 문서가 Kerberos를 언급하지 않을 경우 oozie 클라이언트를 패치해야

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

    } 
} 

답변

3

내 자바 API에서 kerberos를 사용하는 방법을 생각했습니다.

먼저 kerberos tgt를 얻습니다. 커버 로스는 oozie의 문서에서 언급 한

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(); 
     } 
    } 
} 
0

.

+0

하지만 거기에는 예는없고 내가 모두 함께 넣어하는 방법을 알아낼 수 없습니다입니다 :

그런 다음 아래 코드는 작동합니다. –

+0

불량 문서의 티켓을 신청하고 코드의 내용을 검토하십시오. JAAS없이 GSS-API를 사용하고 있다고 가정합니다. –

+0

'org.apache.hadoop.security.authentication.client.KerberosAuthenticator' 클래스는 oozie java API에 대해 kerberos 인증을 구현합니다. 그러나 작동하게하기 위해 따라야 할 예제가 필요합니다. –