MAPREDUCE-4067. Changed MRClientProtocol api to throw IOException only (Xuan Gong via vinodkv)

svn merge --ignore-ancestry -c 1481695 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1481696 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-05-13 03:36:15 +00:00
parent 621db3a3cc
commit 99275f172a
21 changed files with 342 additions and 324 deletions

View File

@ -4,6 +4,9 @@ Release 2.0.5-beta - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES
MAPREDUCE-4067. Changed MRClientProtocol api to throw IOException only (Xuan
Gong via vinodkv)
NEW FEATURES NEW FEATURES
IMPROVEMENTS IMPROVEMENTS

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.mapreduce.v2.app.client; package org.apache.hadoop.mapreduce.v2.app.client;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -81,10 +82,8 @@
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.PolicyProvider; import org.apache.hadoop.security.authorize.PolicyProvider;
import org.apache.hadoop.yarn.api.ApplicationConstants; import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.security.client.ClientToAMTokenSecretManager; import org.apache.hadoop.yarn.security.client.ClientToAMTokenSecretManager;
import org.apache.hadoop.yarn.service.AbstractService; import org.apache.hadoop.yarn.service.AbstractService;
@ -188,34 +187,34 @@ public InetSocketAddress getConnectAddress() {
} }
private Job verifyAndGetJob(JobId jobID, private Job verifyAndGetJob(JobId jobID,
boolean modifyAccess) throws YarnRemoteException { boolean modifyAccess) throws IOException {
Job job = appContext.getJob(jobID); Job job = appContext.getJob(jobID);
return job; return job;
} }
private Task verifyAndGetTask(TaskId taskID, private Task verifyAndGetTask(TaskId taskID,
boolean modifyAccess) throws YarnRemoteException { boolean modifyAccess) throws IOException {
Task task = verifyAndGetJob(taskID.getJobId(), Task task = verifyAndGetJob(taskID.getJobId(),
modifyAccess).getTask(taskID); modifyAccess).getTask(taskID);
if (task == null) { if (task == null) {
throw RPCUtil.getRemoteException("Unknown Task " + taskID); throw new IOException("Unknown Task " + taskID);
} }
return task; return task;
} }
private TaskAttempt verifyAndGetAttempt(TaskAttemptId attemptID, private TaskAttempt verifyAndGetAttempt(TaskAttemptId attemptID,
boolean modifyAccess) throws YarnRemoteException { boolean modifyAccess) throws IOException {
TaskAttempt attempt = verifyAndGetTask(attemptID.getTaskId(), TaskAttempt attempt = verifyAndGetTask(attemptID.getTaskId(),
modifyAccess).getAttempt(attemptID); modifyAccess).getAttempt(attemptID);
if (attempt == null) { if (attempt == null) {
throw RPCUtil.getRemoteException("Unknown TaskAttempt " + attemptID); throw new IOException("Unknown TaskAttempt " + attemptID);
} }
return attempt; return attempt;
} }
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) public GetCountersResponse getCounters(GetCountersRequest request)
throws YarnRemoteException { throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
Job job = verifyAndGetJob(jobId, false); Job job = verifyAndGetJob(jobId, false);
GetCountersResponse response = GetCountersResponse response =
@ -226,7 +225,7 @@ public GetCountersResponse getCounters(GetCountersRequest request)
@Override @Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) public GetJobReportResponse getJobReport(GetJobReportRequest request)
throws YarnRemoteException { throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
Job job = verifyAndGetJob(jobId, false); Job job = verifyAndGetJob(jobId, false);
GetJobReportResponse response = GetJobReportResponse response =
@ -242,7 +241,7 @@ public GetJobReportResponse getJobReport(GetJobReportRequest request)
@Override @Override
public GetTaskAttemptReportResponse getTaskAttemptReport( public GetTaskAttemptReportResponse getTaskAttemptReport(
GetTaskAttemptReportRequest request) throws YarnRemoteException { GetTaskAttemptReportRequest request) throws IOException {
TaskAttemptId taskAttemptId = request.getTaskAttemptId(); TaskAttemptId taskAttemptId = request.getTaskAttemptId();
GetTaskAttemptReportResponse response = GetTaskAttemptReportResponse response =
recordFactory.newRecordInstance(GetTaskAttemptReportResponse.class); recordFactory.newRecordInstance(GetTaskAttemptReportResponse.class);
@ -253,7 +252,7 @@ public GetTaskAttemptReportResponse getTaskAttemptReport(
@Override @Override
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
throws YarnRemoteException { throws IOException {
TaskId taskId = request.getTaskId(); TaskId taskId = request.getTaskId();
GetTaskReportResponse response = GetTaskReportResponse response =
recordFactory.newRecordInstance(GetTaskReportResponse.class); recordFactory.newRecordInstance(GetTaskReportResponse.class);
@ -264,7 +263,7 @@ public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
@Override @Override
public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents( public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(
GetTaskAttemptCompletionEventsRequest request) GetTaskAttemptCompletionEventsRequest request)
throws YarnRemoteException { throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
int fromEventId = request.getFromEventId(); int fromEventId = request.getFromEventId();
int maxEvents = request.getMaxEvents(); int maxEvents = request.getMaxEvents();
@ -280,7 +279,7 @@ public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public KillJobResponse killJob(KillJobRequest request) public KillJobResponse killJob(KillJobRequest request)
throws YarnRemoteException { throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
String message = "Kill Job received from client " + jobId; String message = "Kill Job received from client " + jobId;
LOG.info(message); LOG.info(message);
@ -297,7 +296,7 @@ public KillJobResponse killJob(KillJobRequest request)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public KillTaskResponse killTask(KillTaskRequest request) public KillTaskResponse killTask(KillTaskRequest request)
throws YarnRemoteException { throws IOException {
TaskId taskId = request.getTaskId(); TaskId taskId = request.getTaskId();
String message = "Kill task received from client " + taskId; String message = "Kill task received from client " + taskId;
LOG.info(message); LOG.info(message);
@ -312,7 +311,7 @@ public KillTaskResponse killTask(KillTaskRequest request)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public KillTaskAttemptResponse killTaskAttempt( public KillTaskAttemptResponse killTaskAttempt(
KillTaskAttemptRequest request) throws YarnRemoteException { KillTaskAttemptRequest request) throws IOException {
TaskAttemptId taskAttemptId = request.getTaskAttemptId(); TaskAttemptId taskAttemptId = request.getTaskAttemptId();
String message = "Kill task attempt received from client " + taskAttemptId; String message = "Kill task attempt received from client " + taskAttemptId;
LOG.info(message); LOG.info(message);
@ -329,7 +328,7 @@ public KillTaskAttemptResponse killTaskAttempt(
@Override @Override
public GetDiagnosticsResponse getDiagnostics( public GetDiagnosticsResponse getDiagnostics(
GetDiagnosticsRequest request) throws YarnRemoteException { GetDiagnosticsRequest request) throws IOException {
TaskAttemptId taskAttemptId = request.getTaskAttemptId(); TaskAttemptId taskAttemptId = request.getTaskAttemptId();
GetDiagnosticsResponse response = GetDiagnosticsResponse response =
@ -342,7 +341,7 @@ public GetDiagnosticsResponse getDiagnostics(
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public FailTaskAttemptResponse failTaskAttempt( public FailTaskAttemptResponse failTaskAttempt(
FailTaskAttemptRequest request) throws YarnRemoteException { FailTaskAttemptRequest request) throws IOException {
TaskAttemptId taskAttemptId = request.getTaskAttemptId(); TaskAttemptId taskAttemptId = request.getTaskAttemptId();
String message = "Fail task attempt received from client " + taskAttemptId; String message = "Fail task attempt received from client " + taskAttemptId;
LOG.info(message); LOG.info(message);
@ -361,7 +360,7 @@ public FailTaskAttemptResponse failTaskAttempt(
@Override @Override
public GetTaskReportsResponse getTaskReports( public GetTaskReportsResponse getTaskReports(
GetTaskReportsRequest request) throws YarnRemoteException { GetTaskReportsRequest request) throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
TaskType taskType = request.getTaskType(); TaskType taskType = request.getTaskType();
@ -386,22 +385,22 @@ public GetTaskReportsResponse getTaskReports(
@Override @Override
public GetDelegationTokenResponse getDelegationToken( public GetDelegationTokenResponse getDelegationToken(
GetDelegationTokenRequest request) throws YarnRemoteException { GetDelegationTokenRequest request) throws IOException {
throw RPCUtil.getRemoteException("MR AM not authorized to issue delegation" + throw new IOException("MR AM not authorized to issue delegation" +
" token"); " token");
} }
@Override @Override
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException { RenewDelegationTokenRequest request) throws IOException {
throw RPCUtil.getRemoteException("MR AM not authorized to renew delegation" + throw new IOException("MR AM not authorized to renew delegation" +
" token"); " token");
} }
@Override @Override
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException { CancelDelegationTokenRequest request) throws IOException {
throw RPCUtil.getRemoteException("MR AM not authorized to cancel delegation" + throw new IOException("MR AM not authorized to cancel delegation" +
" token"); " token");
} }
} }

View File

@ -145,13 +145,17 @@ public void init(Configuration conf) {
LOG.info("blacklistDisablePercent is " + blacklistDisablePercent); LOG.info("blacklistDisablePercent is " + blacklistDisablePercent);
} }
protected AllocateResponse makeRemoteRequest() throws YarnRemoteException, protected AllocateResponse makeRemoteRequest() throws IOException {
IOException {
AllocateRequest allocateRequest = BuilderUtils.newAllocateRequest( AllocateRequest allocateRequest = BuilderUtils.newAllocateRequest(
applicationAttemptId, lastResponseID, super.getApplicationProgress(), applicationAttemptId, lastResponseID, super.getApplicationProgress(),
new ArrayList<ResourceRequest>(ask), new ArrayList<ContainerId>( new ArrayList<ResourceRequest>(ask), new ArrayList<ContainerId>(
release)); release));
AllocateResponse allocateResponse = scheduler.allocate(allocateRequest); AllocateResponse allocateResponse;
try {
allocateResponse = scheduler.allocate(allocateRequest);
} catch (YarnRemoteException e) {
throw new IOException(e);
}
lastResponseID = allocateResponse.getResponseId(); lastResponseID = allocateResponse.getResponseId();
availableResources = allocateResponse.getAvailableResources(); availableResources = allocateResponse.getAvailableResources();
lastClusterNmCount = clusterNmCount; lastClusterNmCount = clusterNmCount;

View File

@ -45,7 +45,6 @@
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.service.AbstractService; import org.apache.hadoop.yarn.service.AbstractService;
@ -203,7 +202,7 @@ protected AMRMProtocol createSchedulerProxy() {
public RegisterApplicationMasterResponse public RegisterApplicationMasterResponse
registerApplicationMaster( registerApplicationMaster(
RegisterApplicationMasterRequest request) RegisterApplicationMasterRequest request)
throws YarnRemoteException, IOException { throws IOException {
RegisterApplicationMasterResponse response = RegisterApplicationMasterResponse response =
Records.newRecord(RegisterApplicationMasterResponse.class); Records.newRecord(RegisterApplicationMasterResponse.class);
response.setMinimumResourceCapability(BuilderUtils response.setMinimumResourceCapability(BuilderUtils
@ -216,7 +215,7 @@ protected AMRMProtocol createSchedulerProxy() {
@Override @Override
public FinishApplicationMasterResponse finishApplicationMaster( public FinishApplicationMasterResponse finishApplicationMaster(
FinishApplicationMasterRequest request) FinishApplicationMasterRequest request)
throws YarnRemoteException, IOException { throws IOException {
FinishApplicationMasterResponse response = FinishApplicationMasterResponse response =
Records.newRecord(FinishApplicationMasterResponse.class); Records.newRecord(FinishApplicationMasterResponse.class);
return response; return response;
@ -224,7 +223,7 @@ public FinishApplicationMasterResponse finishApplicationMaster(
@Override @Override
public AllocateResponse allocate(AllocateRequest request) public AllocateResponse allocate(AllocateRequest request)
throws YarnRemoteException, IOException { throws IOException {
AllocateResponse response = AllocateResponse response =
Records.newRecord(AllocateResponse.class); Records.newRecord(AllocateResponse.class);

View File

@ -63,7 +63,6 @@
import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.api.records.ContainerToken; import org.apache.hadoop.yarn.api.records.ContainerToken;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC; import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
@ -366,7 +365,7 @@ public class DummyContainerManager implements ContainerManager {
@Override @Override
public GetContainerStatusResponse getContainerStatus( public GetContainerStatusResponse getContainerStatus(
GetContainerStatusRequest request) throws YarnRemoteException { GetContainerStatusRequest request) throws IOException {
GetContainerStatusResponse response = recordFactory GetContainerStatusResponse response = recordFactory
.newRecordInstance(GetContainerStatusResponse.class); .newRecordInstance(GetContainerStatusResponse.class);
response.setStatus(status); response.setStatus(status);
@ -375,7 +374,7 @@ public GetContainerStatusResponse getContainerStatus(
@Override @Override
public StartContainerResponse startContainer(StartContainerRequest request) public StartContainerResponse startContainer(StartContainerRequest request)
throws YarnRemoteException { throws IOException {
// Validate that the container is what RM is giving. // Validate that the container is what RM is giving.
Assert.assertEquals(MRApp.NM_HOST, request.getContainer().getNodeId() Assert.assertEquals(MRApp.NM_HOST, request.getContainer().getNodeId()
@ -403,10 +402,10 @@ public StartContainerResponse startContainer(StartContainerRequest request)
@Override @Override
public StopContainerResponse stopContainer(StopContainerRequest request) public StopContainerResponse stopContainer(StopContainerRequest request)
throws YarnRemoteException { throws IOException {
Exception e = new Exception("Dummy function", new Exception( Exception e = new Exception("Dummy function", new Exception(
"Dummy function cause")); "Dummy function cause"));
throw new YarnRemoteException(e); throw new IOException(e);
}
} }
} }
}

View File

@ -405,7 +405,7 @@ private static class ContainerManagerForTest implements ContainerManager {
} }
@Override @Override
public StartContainerResponse startContainer(StartContainerRequest request) public StartContainerResponse startContainer(StartContainerRequest request)
throws YarnRemoteException { throws IOException {
try { try {
startLaunchBarrier.await(); startLaunchBarrier.await();
completeLaunchBarrier.await(); completeLaunchBarrier.await();
@ -417,20 +417,20 @@ public StartContainerResponse startContainer(StartContainerRequest request)
e.printStackTrace(); e.printStackTrace();
} }
throw new ContainerException("Force fail CM"); throw new IOException(new ContainerException("Force fail CM"));
} }
@Override @Override
public StopContainerResponse stopContainer(StopContainerRequest request) public StopContainerResponse stopContainer(StopContainerRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetContainerStatusResponse getContainerStatus( public GetContainerStatusResponse getContainerStatus(
GetContainerStatusRequest request) throws YarnRemoteException { GetContainerStatusRequest request) throws IOException {
return null; return null;
} }

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.mapreduce.v2.api; package org.apache.hadoop.mapreduce.v2.api;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest;
@ -48,7 +49,6 @@
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.KillTaskResponse; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.KillTaskResponse;
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenRequest; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenRequest;
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenResponse; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenResponse;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
public interface MRClientProtocol { public interface MRClientProtocol {
/** /**
@ -56,36 +56,36 @@ public interface MRClientProtocol {
* @return InetSocketAddress * @return InetSocketAddress
*/ */
public InetSocketAddress getConnectAddress(); public InetSocketAddress getConnectAddress();
public GetJobReportResponse getJobReport(GetJobReportRequest request) throws YarnRemoteException; public GetJobReportResponse getJobReport(GetJobReportRequest request) throws IOException;
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) throws YarnRemoteException; public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) throws IOException;
public GetTaskAttemptReportResponse getTaskAttemptReport(GetTaskAttemptReportRequest request) throws YarnRemoteException; public GetTaskAttemptReportResponse getTaskAttemptReport(GetTaskAttemptReportRequest request) throws IOException;
public GetCountersResponse getCounters(GetCountersRequest request) throws YarnRemoteException; public GetCountersResponse getCounters(GetCountersRequest request) throws IOException;
public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(GetTaskAttemptCompletionEventsRequest request) throws YarnRemoteException; public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(GetTaskAttemptCompletionEventsRequest request) throws IOException;
public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) throws YarnRemoteException; public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) throws IOException;
public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) throws YarnRemoteException; public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) throws IOException;
public KillJobResponse killJob(KillJobRequest request) throws YarnRemoteException; public KillJobResponse killJob(KillJobRequest request) throws IOException;
public KillTaskResponse killTask(KillTaskRequest request) throws YarnRemoteException; public KillTaskResponse killTask(KillTaskRequest request) throws IOException;
public KillTaskAttemptResponse killTaskAttempt(KillTaskAttemptRequest request) throws YarnRemoteException; public KillTaskAttemptResponse killTaskAttempt(KillTaskAttemptRequest request) throws IOException;
public FailTaskAttemptResponse failTaskAttempt(FailTaskAttemptRequest request) throws YarnRemoteException; public FailTaskAttemptResponse failTaskAttempt(FailTaskAttemptRequest request) throws IOException;
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws YarnRemoteException; public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws IOException;
/** /**
* Renew an existing delegation token. * Renew an existing delegation token.
* *
* @param request the delegation token to be renewed. * @param request the delegation token to be renewed.
* @return the new expiry time for the delegation token. * @return the new expiry time for the delegation token.
* @throws YarnRemoteException * @throws IOException
*/ */
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException; RenewDelegationTokenRequest request) throws IOException;
/** /**
* Cancel an existing delegation token. * Cancel an existing delegation token.
* *
* @param request the delegation token to be cancelled. * @param request the delegation token to be cancelled.
* @return an empty response. * @return an empty response.
* @throws YarnRemoteException * @throws IOException
*/ */
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException; CancelDelegationTokenRequest request) throws IOException;
} }

View File

@ -20,11 +20,13 @@
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.ProtobufRpcEngine;
import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.mapreduce.v2.api.MRClientProtocol; import org.apache.hadoop.mapreduce.v2.api.MRClientProtocol;
import org.apache.hadoop.mapreduce.v2.api.MRClientProtocolPB; import org.apache.hadoop.mapreduce.v2.api.MRClientProtocolPB;
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest;
@ -97,9 +99,6 @@
import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto;
import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto;
import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import com.google.protobuf.ServiceException; import com.google.protobuf.ServiceException;
public class MRClientProtocolPBClientImpl implements MRClientProtocol, public class MRClientProtocolPBClientImpl implements MRClientProtocol,
@ -128,154 +127,154 @@ public void close() {
@Override @Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) public GetJobReportResponse getJobReport(GetJobReportRequest request)
throws YarnRemoteException { throws IOException {
GetJobReportRequestProto requestProto = ((GetJobReportRequestPBImpl)request).getProto(); GetJobReportRequestProto requestProto = ((GetJobReportRequestPBImpl)request).getProto();
try { try {
return new GetJobReportResponsePBImpl(proxy.getJobReport(null, requestProto)); return new GetJobReportResponsePBImpl(proxy.getJobReport(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
throws YarnRemoteException { throws IOException {
GetTaskReportRequestProto requestProto = ((GetTaskReportRequestPBImpl)request).getProto(); GetTaskReportRequestProto requestProto = ((GetTaskReportRequestPBImpl)request).getProto();
try { try {
return new GetTaskReportResponsePBImpl(proxy.getTaskReport(null, requestProto)); return new GetTaskReportResponsePBImpl(proxy.getTaskReport(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetTaskAttemptReportResponse getTaskAttemptReport( public GetTaskAttemptReportResponse getTaskAttemptReport(
GetTaskAttemptReportRequest request) throws YarnRemoteException { GetTaskAttemptReportRequest request) throws IOException {
GetTaskAttemptReportRequestProto requestProto = ((GetTaskAttemptReportRequestPBImpl)request).getProto(); GetTaskAttemptReportRequestProto requestProto = ((GetTaskAttemptReportRequestPBImpl)request).getProto();
try { try {
return new GetTaskAttemptReportResponsePBImpl(proxy.getTaskAttemptReport(null, requestProto)); return new GetTaskAttemptReportResponsePBImpl(proxy.getTaskAttemptReport(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) public GetCountersResponse getCounters(GetCountersRequest request)
throws YarnRemoteException { throws IOException {
GetCountersRequestProto requestProto = ((GetCountersRequestPBImpl)request).getProto(); GetCountersRequestProto requestProto = ((GetCountersRequestPBImpl)request).getProto();
try { try {
return new GetCountersResponsePBImpl(proxy.getCounters(null, requestProto)); return new GetCountersResponsePBImpl(proxy.getCounters(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents( public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(
GetTaskAttemptCompletionEventsRequest request) throws YarnRemoteException { GetTaskAttemptCompletionEventsRequest request) throws IOException {
GetTaskAttemptCompletionEventsRequestProto requestProto = ((GetTaskAttemptCompletionEventsRequestPBImpl)request).getProto(); GetTaskAttemptCompletionEventsRequestProto requestProto = ((GetTaskAttemptCompletionEventsRequestPBImpl)request).getProto();
try { try {
return new GetTaskAttemptCompletionEventsResponsePBImpl(proxy.getTaskAttemptCompletionEvents(null, requestProto)); return new GetTaskAttemptCompletionEventsResponsePBImpl(proxy.getTaskAttemptCompletionEvents(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request)
throws YarnRemoteException { throws IOException {
GetTaskReportsRequestProto requestProto = ((GetTaskReportsRequestPBImpl)request).getProto(); GetTaskReportsRequestProto requestProto = ((GetTaskReportsRequestPBImpl)request).getProto();
try { try {
return new GetTaskReportsResponsePBImpl(proxy.getTaskReports(null, requestProto)); return new GetTaskReportsResponsePBImpl(proxy.getTaskReports(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request)
throws YarnRemoteException { throws IOException {
GetDiagnosticsRequestProto requestProto = ((GetDiagnosticsRequestPBImpl)request).getProto(); GetDiagnosticsRequestProto requestProto = ((GetDiagnosticsRequestPBImpl)request).getProto();
try { try {
return new GetDiagnosticsResponsePBImpl(proxy.getDiagnostics(null, requestProto)); return new GetDiagnosticsResponsePBImpl(proxy.getDiagnostics(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public GetDelegationTokenResponse getDelegationToken( public GetDelegationTokenResponse getDelegationToken(
GetDelegationTokenRequest request) throws YarnRemoteException { GetDelegationTokenRequest request) throws IOException {
GetDelegationTokenRequestProto requestProto = ((GetDelegationTokenRequestPBImpl) GetDelegationTokenRequestProto requestProto = ((GetDelegationTokenRequestPBImpl)
request).getProto(); request).getProto();
try { try {
return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken( return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
null, requestProto)); null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public KillJobResponse killJob(KillJobRequest request) public KillJobResponse killJob(KillJobRequest request)
throws YarnRemoteException { throws IOException {
KillJobRequestProto requestProto = ((KillJobRequestPBImpl)request).getProto(); KillJobRequestProto requestProto = ((KillJobRequestPBImpl)request).getProto();
try { try {
return new KillJobResponsePBImpl(proxy.killJob(null, requestProto)); return new KillJobResponsePBImpl(proxy.killJob(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public KillTaskResponse killTask(KillTaskRequest request) public KillTaskResponse killTask(KillTaskRequest request)
throws YarnRemoteException { throws IOException {
KillTaskRequestProto requestProto = ((KillTaskRequestPBImpl)request).getProto(); KillTaskRequestProto requestProto = ((KillTaskRequestPBImpl)request).getProto();
try { try {
return new KillTaskResponsePBImpl(proxy.killTask(null, requestProto)); return new KillTaskResponsePBImpl(proxy.killTask(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public KillTaskAttemptResponse killTaskAttempt(KillTaskAttemptRequest request) public KillTaskAttemptResponse killTaskAttempt(KillTaskAttemptRequest request)
throws YarnRemoteException { throws IOException {
KillTaskAttemptRequestProto requestProto = ((KillTaskAttemptRequestPBImpl)request).getProto(); KillTaskAttemptRequestProto requestProto = ((KillTaskAttemptRequestPBImpl)request).getProto();
try { try {
return new KillTaskAttemptResponsePBImpl(proxy.killTaskAttempt(null, requestProto)); return new KillTaskAttemptResponsePBImpl(proxy.killTaskAttempt(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public FailTaskAttemptResponse failTaskAttempt(FailTaskAttemptRequest request) public FailTaskAttemptResponse failTaskAttempt(FailTaskAttemptRequest request)
throws YarnRemoteException { throws IOException {
FailTaskAttemptRequestProto requestProto = ((FailTaskAttemptRequestPBImpl)request).getProto(); FailTaskAttemptRequestProto requestProto = ((FailTaskAttemptRequestPBImpl)request).getProto();
try { try {
return new FailTaskAttemptResponsePBImpl(proxy.failTaskAttempt(null, requestProto)); return new FailTaskAttemptResponsePBImpl(proxy.failTaskAttempt(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException { RenewDelegationTokenRequest request) throws IOException {
RenewDelegationTokenRequestProto requestProto = RenewDelegationTokenRequestProto requestProto =
((RenewDelegationTokenRequestPBImpl) request).getProto(); ((RenewDelegationTokenRequestPBImpl) request).getProto();
try { try {
return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken( return new RenewDelegationTokenResponsePBImpl(proxy.renewDelegationToken(
null, requestProto)); null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
} }
} }
@Override @Override
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException { CancelDelegationTokenRequest request) throws IOException {
CancelDelegationTokenRequestProto requestProto = CancelDelegationTokenRequestProto requestProto =
((CancelDelegationTokenRequestPBImpl) request).getProto(); ((CancelDelegationTokenRequestPBImpl) request).getProto();
try { try {
@ -283,7 +282,17 @@ public CancelDelegationTokenResponse cancelDelegationToken(
proxy.cancelDelegationToken(null, requestProto)); proxy.cancelDelegationToken(null, requestProto));
} catch (ServiceException e) { } catch (ServiceException e) {
throw RPCUtil.unwrapAndThrowException(e); throw unwrapAndThrowException(e);
}
}
private IOException unwrapAndThrowException(ServiceException se) {
if (se.getCause() instanceof RemoteException) {
return ((RemoteException) se.getCause()).unwrapRemoteException();
} else if (se.getCause() instanceof IOException) {
return (IOException)se.getCause();
} else {
throw new UndeclaredThrowableException(se.getCause());
} }
} }
} }

View File

@ -18,6 +18,8 @@
package org.apache.hadoop.mapreduce.v2.api.impl.pb.service; package org.apache.hadoop.mapreduce.v2.api.impl.pb.service;
import java.io.IOException;
import org.apache.hadoop.mapreduce.v2.api.MRClientProtocol; import org.apache.hadoop.mapreduce.v2.api.MRClientProtocol;
import org.apache.hadoop.mapreduce.v2.api.MRClientProtocolPB; import org.apache.hadoop.mapreduce.v2.api.MRClientProtocolPB;
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenResponse; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenResponse;
@ -101,8 +103,6 @@
import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProto;
import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto;
import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import com.google.protobuf.RpcController; import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException; import com.google.protobuf.ServiceException;
@ -121,7 +121,7 @@ public GetJobReportResponseProto getJobReport(RpcController controller,
try { try {
GetJobReportResponse response = real.getJobReport(request); GetJobReportResponse response = real.getJobReport(request);
return ((GetJobReportResponsePBImpl)response).getProto(); return ((GetJobReportResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -133,7 +133,7 @@ public GetTaskReportResponseProto getTaskReport(RpcController controller,
try { try {
GetTaskReportResponse response = real.getTaskReport(request); GetTaskReportResponse response = real.getTaskReport(request);
return ((GetTaskReportResponsePBImpl)response).getProto(); return ((GetTaskReportResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -146,7 +146,7 @@ public GetTaskAttemptReportResponseProto getTaskAttemptReport(
try { try {
GetTaskAttemptReportResponse response = real.getTaskAttemptReport(request); GetTaskAttemptReportResponse response = real.getTaskAttemptReport(request);
return ((GetTaskAttemptReportResponsePBImpl)response).getProto(); return ((GetTaskAttemptReportResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -158,7 +158,7 @@ public GetCountersResponseProto getCounters(RpcController controller,
try { try {
GetCountersResponse response = real.getCounters(request); GetCountersResponse response = real.getCounters(request);
return ((GetCountersResponsePBImpl)response).getProto(); return ((GetCountersResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -172,7 +172,7 @@ public GetTaskAttemptCompletionEventsResponseProto getTaskAttemptCompletionEvent
try { try {
GetTaskAttemptCompletionEventsResponse response = real.getTaskAttemptCompletionEvents(request); GetTaskAttemptCompletionEventsResponse response = real.getTaskAttemptCompletionEvents(request);
return ((GetTaskAttemptCompletionEventsResponsePBImpl)response).getProto(); return ((GetTaskAttemptCompletionEventsResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -184,7 +184,7 @@ public GetTaskReportsResponseProto getTaskReports(RpcController controller,
try { try {
GetTaskReportsResponse response = real.getTaskReports(request); GetTaskReportsResponse response = real.getTaskReports(request);
return ((GetTaskReportsResponsePBImpl)response).getProto(); return ((GetTaskReportsResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -196,7 +196,7 @@ public GetDiagnosticsResponseProto getDiagnostics(RpcController controller,
try { try {
GetDiagnosticsResponse response = real.getDiagnostics(request); GetDiagnosticsResponse response = real.getDiagnostics(request);
return ((GetDiagnosticsResponsePBImpl)response).getProto(); return ((GetDiagnosticsResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -209,7 +209,7 @@ public GetDelegationTokenResponseProto getDelegationToken(
try { try {
GetDelegationTokenResponse response = real.getDelegationToken(request); GetDelegationTokenResponse response = real.getDelegationToken(request);
return ((GetDelegationTokenResponsePBImpl)response).getProto(); return ((GetDelegationTokenResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -221,7 +221,7 @@ public KillJobResponseProto killJob(RpcController controller,
try { try {
KillJobResponse response = real.killJob(request); KillJobResponse response = real.killJob(request);
return ((KillJobResponsePBImpl)response).getProto(); return ((KillJobResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -233,7 +233,7 @@ public KillTaskResponseProto killTask(RpcController controller,
try { try {
KillTaskResponse response = real.killTask(request); KillTaskResponse response = real.killTask(request);
return ((KillTaskResponsePBImpl)response).getProto(); return ((KillTaskResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -245,7 +245,7 @@ public KillTaskAttemptResponseProto killTaskAttempt(RpcController controller,
try { try {
KillTaskAttemptResponse response = real.killTaskAttempt(request); KillTaskAttemptResponse response = real.killTaskAttempt(request);
return ((KillTaskAttemptResponsePBImpl)response).getProto(); return ((KillTaskAttemptResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -257,7 +257,7 @@ public FailTaskAttemptResponseProto failTaskAttempt(RpcController controller,
try { try {
FailTaskAttemptResponse response = real.failTaskAttempt(request); FailTaskAttemptResponse response = real.failTaskAttempt(request);
return ((FailTaskAttemptResponsePBImpl)response).getProto(); return ((FailTaskAttemptResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -271,7 +271,7 @@ public RenewDelegationTokenResponseProto renewDelegationToken(
try { try {
RenewDelegationTokenResponse response = real.renewDelegationToken(request); RenewDelegationTokenResponse response = real.renewDelegationToken(request);
return ((RenewDelegationTokenResponsePBImpl)response).getProto(); return ((RenewDelegationTokenResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }
@ -285,7 +285,7 @@ public CancelDelegationTokenResponseProto cancelDelegationToken(
try { try {
CancelDelegationTokenResponse response = real.cancelDelegationToken(request); CancelDelegationTokenResponse response = real.cancelDelegationToken(request);
return ((CancelDelegationTokenResponsePBImpl)response).getProto(); return ((CancelDelegationTokenResponsePBImpl)response).getProto();
} catch (YarnRemoteException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
} }

View File

@ -37,7 +37,6 @@
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenRenewer; import org.apache.hadoop.security.token.TokenRenewer;
import org.apache.hadoop.yarn.api.records.DelegationToken; import org.apache.hadoop.yarn.api.records.DelegationToken;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.util.BuilderUtils; import org.apache.hadoop.yarn.util.BuilderUtils;
import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.Records;
@ -68,8 +67,6 @@ public long renew(Token<?> token, Configuration conf) throws IOException,
.newRecord(RenewDelegationTokenRequest.class); .newRecord(RenewDelegationTokenRequest.class);
request.setDelegationToken(dToken); request.setDelegationToken(dToken);
return histProxy.renewDelegationToken(request).getNextExpirationTime(); return histProxy.renewDelegationToken(request).getNextExpirationTime();
} catch (YarnRemoteException e) {
throw new IOException(e);
} finally { } finally {
stopHistoryProxy(histProxy); stopHistoryProxy(histProxy);
} }
@ -91,8 +88,6 @@ public void cancel(Token<?> token, Configuration conf) throws IOException,
.newRecord(CancelDelegationTokenRequest.class); .newRecord(CancelDelegationTokenRequest.class);
request.setDelegationToken(dToken); request.setDelegationToken(dToken);
histProxy.cancelDelegationToken(request); histProxy.cancelDelegationToken(request);
} catch (YarnRemoteException e) {
throw new IOException(e);
} finally { } finally {
stopHistoryProxy(histProxy); stopHistoryProxy(histProxy);
} }

View File

@ -19,6 +19,7 @@
package org.apache.hadoop.mapreduce.v2; package org.apache.hadoop.mapreduce.v2;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import junit.framework.Assert; import junit.framework.Assert;
@ -56,7 +57,6 @@
import org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenResponse; import org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenResponse;
import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.yarn.YarnException; import org.apache.hadoop.yarn.YarnException;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl; import org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl;
import org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl; import org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl;
import org.junit.Test; import org.junit.Test;
@ -133,86 +133,86 @@ public InetSocketAddress getConnectAddress() {
@Override @Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) public GetJobReportResponse getJobReport(GetJobReportRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetTaskAttemptReportResponse getTaskAttemptReport( public GetTaskAttemptReportResponse getTaskAttemptReport(
GetTaskAttemptReportRequest request) throws YarnRemoteException { GetTaskAttemptReportRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) public GetCountersResponse getCounters(GetCountersRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents( public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(
GetTaskAttemptCompletionEventsRequest request) GetTaskAttemptCompletionEventsRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public KillJobResponse killJob(KillJobRequest request) public KillJobResponse killJob(KillJobRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public KillTaskResponse killTask(KillTaskRequest request) public KillTaskResponse killTask(KillTaskRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public KillTaskAttemptResponse killTaskAttempt( public KillTaskAttemptResponse killTaskAttempt(
KillTaskAttemptRequest request) throws YarnRemoteException { KillTaskAttemptRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public FailTaskAttemptResponse failTaskAttempt( public FailTaskAttemptResponse failTaskAttempt(
FailTaskAttemptRequest request) throws YarnRemoteException { FailTaskAttemptRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetDelegationTokenResponse getDelegationToken( public GetDelegationTokenResponse getDelegationToken(
GetDelegationTokenRequest request) throws YarnRemoteException { GetDelegationTokenRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException { RenewDelegationTokenRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException { CancelDelegationTokenRequest request) throws IOException {
return null; return null;
} }
} }

View File

@ -80,10 +80,8 @@
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod; import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.yarn.api.records.DelegationToken; import org.apache.hadoop.yarn.api.records.DelegationToken;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.service.AbstractService; import org.apache.hadoop.yarn.service.AbstractService;
import org.apache.hadoop.yarn.util.BuilderUtils; import org.apache.hadoop.yarn.util.BuilderUtils;
@ -187,7 +185,7 @@ public InetSocketAddress getConnectAddress() {
return getBindAddress(); return getBindAddress();
} }
private Job verifyAndGetJob(final JobId jobID) throws YarnRemoteException { private Job verifyAndGetJob(final JobId jobID) throws IOException {
UserGroupInformation loginUgi = null; UserGroupInformation loginUgi = null;
Job job = null; Job job = null;
try { try {
@ -200,10 +198,8 @@ public Job run() throws Exception {
return job; return job;
} }
}); });
} catch (IOException e) {
throw RPCUtil.getRemoteException(e);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw RPCUtil.getRemoteException(e); throw new IOException(e);
} }
if (job != null) { if (job != null) {
JobACL operation = JobACL.VIEW_JOB; JobACL operation = JobACL.VIEW_JOB;
@ -213,7 +209,8 @@ public Job run() throws Exception {
} }
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) throws YarnRemoteException { public GetCountersResponse getCounters(GetCountersRequest request)
throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
Job job = verifyAndGetJob(jobId); Job job = verifyAndGetJob(jobId);
GetCountersResponse response = recordFactory.newRecordInstance(GetCountersResponse.class); GetCountersResponse response = recordFactory.newRecordInstance(GetCountersResponse.class);
@ -222,7 +219,8 @@ public GetCountersResponse getCounters(GetCountersRequest request) throws YarnRe
} }
@Override @Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) throws YarnRemoteException { public GetJobReportResponse getJobReport(GetJobReportRequest request)
throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
Job job = verifyAndGetJob(jobId); Job job = verifyAndGetJob(jobId);
GetJobReportResponse response = recordFactory.newRecordInstance(GetJobReportResponse.class); GetJobReportResponse response = recordFactory.newRecordInstance(GetJobReportResponse.class);
@ -236,7 +234,8 @@ public GetJobReportResponse getJobReport(GetJobReportRequest request) throws Yar
} }
@Override @Override
public GetTaskAttemptReportResponse getTaskAttemptReport(GetTaskAttemptReportRequest request) throws YarnRemoteException { public GetTaskAttemptReportResponse getTaskAttemptReport(
GetTaskAttemptReportRequest request) throws IOException {
TaskAttemptId taskAttemptId = request.getTaskAttemptId(); TaskAttemptId taskAttemptId = request.getTaskAttemptId();
Job job = verifyAndGetJob(taskAttemptId.getTaskId().getJobId()); Job job = verifyAndGetJob(taskAttemptId.getTaskId().getJobId());
GetTaskAttemptReportResponse response = recordFactory.newRecordInstance(GetTaskAttemptReportResponse.class); GetTaskAttemptReportResponse response = recordFactory.newRecordInstance(GetTaskAttemptReportResponse.class);
@ -245,7 +244,8 @@ public GetTaskAttemptReportResponse getTaskAttemptReport(GetTaskAttemptReportReq
} }
@Override @Override
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) throws YarnRemoteException { public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
throws IOException {
TaskId taskId = request.getTaskId(); TaskId taskId = request.getTaskId();
Job job = verifyAndGetJob(taskId.getJobId()); Job job = verifyAndGetJob(taskId.getJobId());
GetTaskReportResponse response = recordFactory.newRecordInstance(GetTaskReportResponse.class); GetTaskReportResponse response = recordFactory.newRecordInstance(GetTaskReportResponse.class);
@ -254,7 +254,9 @@ public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) throws
} }
@Override @Override
public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(GetTaskAttemptCompletionEventsRequest request) throws YarnRemoteException { public GetTaskAttemptCompletionEventsResponse
getTaskAttemptCompletionEvents(
GetTaskAttemptCompletionEventsRequest request) throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
int fromEventId = request.getFromEventId(); int fromEventId = request.getFromEventId();
int maxEvents = request.getMaxEvents(); int maxEvents = request.getMaxEvents();
@ -266,22 +268,25 @@ public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(Get
} }
@Override @Override
public KillJobResponse killJob(KillJobRequest request) throws YarnRemoteException { public KillJobResponse killJob(KillJobRequest request) throws IOException {
throw RPCUtil.getRemoteException("Invalid operation on completed job"); throw new IOException("Invalid operation on completed job");
} }
@Override @Override
public KillTaskResponse killTask(KillTaskRequest request) throws YarnRemoteException { public KillTaskResponse killTask(KillTaskRequest request)
throw RPCUtil.getRemoteException("Invalid operation on completed job"); throws IOException {
throw new IOException("Invalid operation on completed job");
} }
@Override @Override
public KillTaskAttemptResponse killTaskAttempt(KillTaskAttemptRequest request) throws YarnRemoteException { public KillTaskAttemptResponse killTaskAttempt(
throw RPCUtil.getRemoteException("Invalid operation on completed job"); KillTaskAttemptRequest request) throws IOException {
throw new IOException("Invalid operation on completed job");
} }
@Override @Override
public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) throws YarnRemoteException { public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request)
throws IOException {
TaskAttemptId taskAttemptId = request.getTaskAttemptId(); TaskAttemptId taskAttemptId = request.getTaskAttemptId();
Job job = verifyAndGetJob(taskAttemptId.getTaskId().getJobId()); Job job = verifyAndGetJob(taskAttemptId.getTaskId().getJobId());
@ -292,12 +297,14 @@ public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) thro
} }
@Override @Override
public FailTaskAttemptResponse failTaskAttempt(FailTaskAttemptRequest request) throws YarnRemoteException { public FailTaskAttemptResponse failTaskAttempt(
throw RPCUtil.getRemoteException("Invalid operation on completed job"); FailTaskAttemptRequest request) throws IOException {
throw new IOException("Invalid operation on completed job");
} }
@Override @Override
public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) throws YarnRemoteException { public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request)
throws IOException {
JobId jobId = request.getJobId(); JobId jobId = request.getJobId();
TaskType taskType = request.getTaskType(); TaskType taskType = request.getTaskType();
@ -312,9 +319,7 @@ public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) thro
@Override @Override
public GetDelegationTokenResponse getDelegationToken( public GetDelegationTokenResponse getDelegationToken(
GetDelegationTokenRequest request) throws YarnRemoteException { GetDelegationTokenRequest request) throws IOException {
try {
UserGroupInformation ugi = UserGroupInformation.getCurrentUser(); UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
@ -344,22 +349,19 @@ public GetDelegationTokenResponse getDelegationToken(
realJHSToken.getPassword(), realJHSToken.getService().toString()); realJHSToken.getPassword(), realJHSToken.getService().toString());
response.setDelegationToken(mrDToken); response.setDelegationToken(mrDToken);
return response; return response;
} catch (IOException i) {
throw RPCUtil.getRemoteException(i);
}
} }
@Override @Override
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException { RenewDelegationTokenRequest request) throws IOException {
try {
if (!isAllowedDelegationTokenOp()) { if (!isAllowedDelegationTokenOp()) {
throw new IOException( throw new IOException(
"Delegation Token can be renewed only with kerberos authentication"); "Delegation Token can be renewed only with kerberos authentication");
} }
DelegationToken protoToken = request.getDelegationToken(); DelegationToken protoToken = request.getDelegationToken();
Token<MRDelegationTokenIdentifier> token = new Token<MRDelegationTokenIdentifier>( Token<MRDelegationTokenIdentifier> token =
new Token<MRDelegationTokenIdentifier>(
protoToken.getIdentifier().array(), protoToken.getPassword() protoToken.getIdentifier().array(), protoToken.getPassword()
.array(), new Text(protoToken.getKind()), new Text( .array(), new Text(protoToken.getKind()), new Text(
protoToken.getService())); protoToken.getService()));
@ -370,22 +372,19 @@ public RenewDelegationTokenResponse renewDelegationToken(
.newRecord(RenewDelegationTokenResponse.class); .newRecord(RenewDelegationTokenResponse.class);
renewResponse.setNextExpirationTime(nextExpTime); renewResponse.setNextExpirationTime(nextExpTime);
return renewResponse; return renewResponse;
} catch (IOException e) {
throw RPCUtil.getRemoteException(e);
}
} }
@Override @Override
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException { CancelDelegationTokenRequest request) throws IOException {
try {
if (!isAllowedDelegationTokenOp()) { if (!isAllowedDelegationTokenOp()) {
throw new IOException( throw new IOException(
"Delegation Token can be cancelled only with kerberos authentication"); "Delegation Token can be cancelled only with kerberos authentication");
} }
DelegationToken protoToken = request.getDelegationToken(); DelegationToken protoToken = request.getDelegationToken();
Token<MRDelegationTokenIdentifier> token = new Token<MRDelegationTokenIdentifier>( Token<MRDelegationTokenIdentifier> token =
new Token<MRDelegationTokenIdentifier>(
protoToken.getIdentifier().array(), protoToken.getPassword() protoToken.getIdentifier().array(), protoToken.getPassword()
.array(), new Text(protoToken.getKind()), new Text( .array(), new Text(protoToken.getKind()), new Text(
protoToken.getService())); protoToken.getService()));
@ -393,22 +392,16 @@ public CancelDelegationTokenResponse cancelDelegationToken(
String user = UserGroupInformation.getCurrentUser().getShortUserName(); String user = UserGroupInformation.getCurrentUser().getShortUserName();
jhsDTSecretManager.cancelToken(token, user); jhsDTSecretManager.cancelToken(token, user);
return Records.newRecord(CancelDelegationTokenResponse.class); return Records.newRecord(CancelDelegationTokenResponse.class);
} catch (IOException e) {
throw RPCUtil.getRemoteException(e);
}
} }
private void checkAccess(Job job, JobACL jobOperation) private void checkAccess(Job job, JobACL jobOperation)
throws YarnRemoteException { throws IOException {
UserGroupInformation callerUGI; UserGroupInformation callerUGI;
try {
callerUGI = UserGroupInformation.getCurrentUser(); callerUGI = UserGroupInformation.getCurrentUser();
} catch (IOException e) {
throw RPCUtil.getRemoteException(e);
}
if (!job.checkAccess(callerUGI, jobOperation)) { if (!job.checkAccess(callerUGI, jobOperation)) {
throw RPCUtil.getRemoteException(new AccessControlException("User " throw new IOException(new AccessControlException("User "
+ callerUGI.getShortUserName() + " cannot perform operation " + callerUGI.getShortUserName() + " cannot perform operation "
+ jobOperation.name() + " on " + job.getID())); + jobOperation.name() + " on " + job.getID()));
} }

View File

@ -75,7 +75,6 @@
import org.apache.hadoop.yarn.exceptions.YarnRemoteException; import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.security.client.ClientTokenIdentifier; import org.apache.hadoop.yarn.security.client.ClientTokenIdentifier;
import org.apache.hadoop.yarn.util.BuilderUtils; import org.apache.hadoop.yarn.util.BuilderUtils;
@ -137,14 +136,19 @@ private NotRunningJob getNotRunningJob(ApplicationReport applicationReport,
} }
} }
private MRClientProtocol getProxy() throws YarnRemoteException, IOException { private MRClientProtocol getProxy() throws IOException {
if (realProxy != null) { if (realProxy != null) {
return realProxy; return realProxy;
} }
// Possibly allow nulls through the PB tunnel, otherwise deal with an exception // Possibly allow nulls through the PB tunnel, otherwise deal with an exception
// and redirect to the history server. // and redirect to the history server.
ApplicationReport application = rm.getApplicationReport(appId); ApplicationReport application = null;
try {
application = rm.getApplicationReport(appId);
} catch (YarnRemoteException e2) {
throw new IOException(e2);
}
if (application != null) { if (application != null) {
trackingUrl = application.getTrackingUrl(); trackingUrl = application.getTrackingUrl();
} }
@ -213,7 +217,11 @@ public MRClientProtocol run() throws IOException {
LOG.warn("getProxy() call interruped", e1); LOG.warn("getProxy() call interruped", e1);
throw new YarnException(e1); throw new YarnException(e1);
} }
try {
application = rm.getApplicationReport(appId); application = rm.getApplicationReport(appId);
} catch (YarnRemoteException e1) {
throw new IOException(e1);
}
if (application == null) { if (application == null) {
LOG.info("Could not get Job info from RM for job " + jobId LOG.info("Could not get Job info from RM for job " + jobId
+ ". Redirecting to job history server."); + ". Redirecting to job history server.");
@ -222,6 +230,8 @@ public MRClientProtocol run() throws IOException {
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOG.warn("getProxy() call interruped", e); LOG.warn("getProxy() call interruped", e);
throw new YarnException(e); throw new YarnException(e);
} catch (YarnRemoteException e) {
throw new IOException(e);
} }
} }
@ -231,7 +241,7 @@ public MRClientProtocol run() throws IOException {
*/ */
String user = application.getUser(); String user = application.getUser();
if (user == null) { if (user == null) {
throw RPCUtil.getRemoteException("User is not set in the application report"); throw new IOException("User is not set in the application report");
} }
if (application.getYarnApplicationState() == YarnApplicationState.NEW if (application.getYarnApplicationState() == YarnApplicationState.NEW
|| application.getYarnApplicationState() == || application.getYarnApplicationState() ==
@ -300,23 +310,15 @@ private synchronized Object invoke(String method, Class argClass,
while (maxRetries > 0) { while (maxRetries > 0) {
try { try {
return methodOb.invoke(getProxy(), args); return methodOb.invoke(getProxy(), args);
} catch (YarnRemoteException yre) {
LOG.warn("Exception thrown by remote end.", yre);
throw new IOException(yre);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getTargetException() instanceof YarnRemoteException) { // Will not throw out YarnRemoteException anymore
LOG.warn("Error from remote end: " + e
.getTargetException().getLocalizedMessage());
LOG.debug("Tracing remote error ", e.getTargetException());
throw new IOException(e.getTargetException());
}
LOG.debug("Failed to contact AM/History for job " + jobId + LOG.debug("Failed to contact AM/History for job " + jobId +
" retrying..", e.getTargetException()); " retrying..", e.getTargetException());
// Force reconnection by setting the proxy to null. // Force reconnection by setting the proxy to null.
realProxy = null; realProxy = null;
// HS/AMS shut down // HS/AMS shut down
maxRetries--; maxRetries--;
lastException = new IOException(e.getMessage()); lastException = new IOException(e.getTargetException());
} catch (Exception e) { } catch (Exception e) {
LOG.debug("Failed to contact AM/History for job " + jobId LOG.debug("Failed to contact AM/History for job " + jobId
@ -447,7 +449,7 @@ public boolean killJob(JobID oldJobID)
} }
public LogParams getLogFilePath(JobID oldJobID, TaskAttemptID oldTaskAttemptID) public LogParams getLogFilePath(JobID oldJobID, TaskAttemptID oldTaskAttemptID)
throws YarnRemoteException, IOException { throws IOException {
org.apache.hadoop.mapreduce.v2.api.records.JobId jobId = org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
TypeConverter.toYarn(oldJobID); TypeConverter.toYarn(oldJobID);
GetJobReportRequest request = GetJobReportRequest request =

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.mapred; package org.apache.hadoop.mapred;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -65,7 +66,6 @@
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.util.BuilderUtils; import org.apache.hadoop.yarn.util.BuilderUtils;
@ -101,7 +101,7 @@ private ApplicationReport getUnknownApplicationReport() {
@Override @Override
public FailTaskAttemptResponse failTaskAttempt( public FailTaskAttemptResponse failTaskAttempt(
FailTaskAttemptRequest request) throws YarnRemoteException { FailTaskAttemptRequest request) throws IOException {
FailTaskAttemptResponse resp = FailTaskAttemptResponse resp =
recordFactory.newRecordInstance(FailTaskAttemptResponse.class); recordFactory.newRecordInstance(FailTaskAttemptResponse.class);
return resp; return resp;
@ -109,7 +109,7 @@ public FailTaskAttemptResponse failTaskAttempt(
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) public GetCountersResponse getCounters(GetCountersRequest request)
throws YarnRemoteException { throws IOException {
GetCountersResponse resp = GetCountersResponse resp =
recordFactory.newRecordInstance(GetCountersResponse.class); recordFactory.newRecordInstance(GetCountersResponse.class);
Counters counters = recordFactory.newRecordInstance(Counters.class); Counters counters = recordFactory.newRecordInstance(Counters.class);
@ -120,7 +120,7 @@ public GetCountersResponse getCounters(GetCountersRequest request)
@Override @Override
public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request) public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request)
throws YarnRemoteException { throws IOException {
GetDiagnosticsResponse resp = GetDiagnosticsResponse resp =
recordFactory.newRecordInstance(GetDiagnosticsResponse.class); recordFactory.newRecordInstance(GetDiagnosticsResponse.class);
resp.addDiagnostics(""); resp.addDiagnostics("");
@ -129,7 +129,7 @@ public GetDiagnosticsResponse getDiagnostics(GetDiagnosticsRequest request)
@Override @Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) public GetJobReportResponse getJobReport(GetJobReportRequest request)
throws YarnRemoteException { throws IOException {
JobReport jobReport = JobReport jobReport =
recordFactory.newRecordInstance(JobReport.class); recordFactory.newRecordInstance(JobReport.class);
jobReport.setJobId(request.getJobId()); jobReport.setJobId(request.getJobId());
@ -150,7 +150,7 @@ public GetJobReportResponse getJobReport(GetJobReportRequest request)
@Override @Override
public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents( public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(
GetTaskAttemptCompletionEventsRequest request) GetTaskAttemptCompletionEventsRequest request)
throws YarnRemoteException { throws IOException {
GetTaskAttemptCompletionEventsResponse resp = GetTaskAttemptCompletionEventsResponse resp =
recordFactory.newRecordInstance(GetTaskAttemptCompletionEventsResponse.class); recordFactory.newRecordInstance(GetTaskAttemptCompletionEventsResponse.class);
resp.addAllCompletionEvents(new ArrayList<TaskAttemptCompletionEvent>()); resp.addAllCompletionEvents(new ArrayList<TaskAttemptCompletionEvent>());
@ -159,14 +159,14 @@ public GetTaskAttemptCompletionEventsResponse getTaskAttemptCompletionEvents(
@Override @Override
public GetTaskAttemptReportResponse getTaskAttemptReport( public GetTaskAttemptReportResponse getTaskAttemptReport(
GetTaskAttemptReportRequest request) throws YarnRemoteException { GetTaskAttemptReportRequest request) throws IOException {
//not invoked by anybody //not invoked by anybody
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override @Override
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
throws YarnRemoteException { throws IOException {
GetTaskReportResponse resp = GetTaskReportResponse resp =
recordFactory.newRecordInstance(GetTaskReportResponse.class); recordFactory.newRecordInstance(GetTaskReportResponse.class);
TaskReport report = recordFactory.newRecordInstance(TaskReport.class); TaskReport report = recordFactory.newRecordInstance(TaskReport.class);
@ -181,7 +181,7 @@ public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
@Override @Override
public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request) public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request)
throws YarnRemoteException { throws IOException {
GetTaskReportsResponse resp = GetTaskReportsResponse resp =
recordFactory.newRecordInstance(GetTaskReportsResponse.class); recordFactory.newRecordInstance(GetTaskReportsResponse.class);
resp.addAllTaskReports(new ArrayList<TaskReport>()); resp.addAllTaskReports(new ArrayList<TaskReport>());
@ -190,7 +190,7 @@ public GetTaskReportsResponse getTaskReports(GetTaskReportsRequest request)
@Override @Override
public KillJobResponse killJob(KillJobRequest request) public KillJobResponse killJob(KillJobRequest request)
throws YarnRemoteException { throws IOException {
KillJobResponse resp = KillJobResponse resp =
recordFactory.newRecordInstance(KillJobResponse.class); recordFactory.newRecordInstance(KillJobResponse.class);
return resp; return resp;
@ -198,7 +198,7 @@ public KillJobResponse killJob(KillJobRequest request)
@Override @Override
public KillTaskResponse killTask(KillTaskRequest request) public KillTaskResponse killTask(KillTaskRequest request)
throws YarnRemoteException { throws IOException {
KillTaskResponse resp = KillTaskResponse resp =
recordFactory.newRecordInstance(KillTaskResponse.class); recordFactory.newRecordInstance(KillTaskResponse.class);
return resp; return resp;
@ -206,7 +206,7 @@ public KillTaskResponse killTask(KillTaskRequest request)
@Override @Override
public KillTaskAttemptResponse killTaskAttempt( public KillTaskAttemptResponse killTaskAttempt(
KillTaskAttemptRequest request) throws YarnRemoteException { KillTaskAttemptRequest request) throws IOException {
KillTaskAttemptResponse resp = KillTaskAttemptResponse resp =
recordFactory.newRecordInstance(KillTaskAttemptResponse.class); recordFactory.newRecordInstance(KillTaskAttemptResponse.class);
return resp; return resp;
@ -214,21 +214,21 @@ public KillTaskAttemptResponse killTaskAttempt(
@Override @Override
public GetDelegationTokenResponse getDelegationToken( public GetDelegationTokenResponse getDelegationToken(
GetDelegationTokenRequest request) throws YarnRemoteException { GetDelegationTokenRequest request) throws IOException {
/* Should not be invoked by anyone. */ /* Should not be invoked by anyone. */
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override @Override
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException { RenewDelegationTokenRequest request) throws IOException {
/* Should not be invoked by anyone. */ /* Should not be invoked by anyone. */
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override @Override
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException { CancelDelegationTokenRequest request) throws IOException {
/* Should not be invoked by anyone. */ /* Should not be invoked by anyone. */
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -209,14 +209,10 @@ Token<?> getDelegationTokenFromHS(MRClientProtocol hsProxy)
.newRecordInstance(GetDelegationTokenRequest.class); .newRecordInstance(GetDelegationTokenRequest.class);
request.setRenewer(Master.getMasterPrincipal(conf)); request.setRenewer(Master.getMasterPrincipal(conf));
DelegationToken mrDelegationToken; DelegationToken mrDelegationToken;
try {
mrDelegationToken = hsProxy.getDelegationToken(request) mrDelegationToken = hsProxy.getDelegationToken(request)
.getDelegationToken(); .getDelegationToken();
return ProtoUtils.convertFromProtoFormat(mrDelegationToken, return ProtoUtils.convertFromProtoFormat(mrDelegationToken,
hsProxy.getConnectAddress()); hsProxy.getConnectAddress());
} catch (YarnRemoteException e) {
throw new IOException(e);
}
} }
@Override @Override
@ -627,11 +623,7 @@ public ProtocolSignature getProtocolSignature(String protocol,
@Override @Override
public LogParams getLogFileParams(JobID jobID, TaskAttemptID taskAttemptID) public LogParams getLogFileParams(JobID jobID, TaskAttemptID taskAttemptID)
throws IOException { throws IOException {
try {
return clientCache.getClient(jobID).getLogFilePath(jobID, taskAttemptID); return clientCache.getClient(jobID).getLogFilePath(jobID, taskAttemptID);
} catch (YarnRemoteException e) {
throw new IOException(e);
}
} }
private static void warnForJavaLibPath(String opts, String component, private static void warnForJavaLibPath(String opts, String component,

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.mapred; package org.apache.hadoop.mapred;
import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -98,7 +99,6 @@
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
@ -257,13 +257,14 @@ public void start() {
} }
@Override @Override
public GetNewApplicationResponse getNewApplication(GetNewApplicationRequest request) throws YarnRemoteException { public GetNewApplicationResponse getNewApplication(
GetNewApplicationRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetApplicationReportResponse getApplicationReport( public GetApplicationReportResponse getApplicationReport(
GetApplicationReportRequest request) throws YarnRemoteException { GetApplicationReportRequest request) throws IOException {
ApplicationId applicationId = request.getApplicationId(); ApplicationId applicationId = request.getApplicationId();
ApplicationReport application = recordFactory ApplicationReport application = recordFactory
.newRecordInstance(ApplicationReport.class); .newRecordInstance(ApplicationReport.class);
@ -296,61 +297,61 @@ public GetApplicationReportResponse getApplicationReport(
@Override @Override
public SubmitApplicationResponse submitApplication( public SubmitApplicationResponse submitApplication(
SubmitApplicationRequest request) throws YarnRemoteException { SubmitApplicationRequest request) throws IOException {
throw new YarnRemoteException("Test"); throw new IOException("Test");
} }
@Override @Override
public KillApplicationResponse forceKillApplication( public KillApplicationResponse forceKillApplication(
KillApplicationRequest request) throws YarnRemoteException { KillApplicationRequest request) throws IOException {
return recordFactory.newRecordInstance(KillApplicationResponse.class); return recordFactory.newRecordInstance(KillApplicationResponse.class);
} }
@Override @Override
public GetClusterMetricsResponse getClusterMetrics( public GetClusterMetricsResponse getClusterMetrics(
GetClusterMetricsRequest request) throws YarnRemoteException { GetClusterMetricsRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetAllApplicationsResponse getAllApplications( public GetAllApplicationsResponse getAllApplications(
GetAllApplicationsRequest request) throws YarnRemoteException { GetAllApplicationsRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetClusterNodesResponse getClusterNodes( public GetClusterNodesResponse getClusterNodes(
GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetQueueUserAclsInfoResponse getQueueUserAcls( public GetQueueUserAclsInfoResponse getQueueUserAcls(
GetQueueUserAclsInfoRequest request) throws YarnRemoteException { GetQueueUserAclsInfoRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public GetDelegationTokenResponse getDelegationToken( public GetDelegationTokenResponse getDelegationToken(
GetDelegationTokenRequest request) throws YarnRemoteException { GetDelegationTokenRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public RenewDelegationTokenResponse renewDelegationToken( public RenewDelegationTokenResponse renewDelegationToken(
RenewDelegationTokenRequest request) throws YarnRemoteException { RenewDelegationTokenRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public CancelDelegationTokenResponse cancelDelegationToken( public CancelDelegationTokenResponse cancelDelegationToken(
CancelDelegationTokenRequest request) throws YarnRemoteException { CancelDelegationTokenRequest request) throws IOException {
return null; return null;
} }
} }
@ -362,7 +363,8 @@ public HistoryService() {
} }
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) throws YarnRemoteException { public GetCountersResponse getCounters(GetCountersRequest request)
throws IOException {
hsContact = true; hsContact = true;
Counters counters = getMyCounters(); Counters counters = getMyCounters();
GetCountersResponse response = recordFactory.newRecordInstance(GetCountersResponse.class); GetCountersResponse response = recordFactory.newRecordInstance(GetCountersResponse.class);
@ -422,7 +424,7 @@ public void stop() {
@Override @Override
public GetCountersResponse getCounters(GetCountersRequest request) public GetCountersResponse getCounters(GetCountersRequest request)
throws YarnRemoteException { throws IOException {
JobId jobID = request.getJobId(); JobId jobID = request.getJobId();
amContact = true; amContact = true;
@ -436,7 +438,7 @@ public GetCountersResponse getCounters(GetCountersRequest request)
@Override @Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) public GetJobReportResponse getJobReport(GetJobReportRequest request)
throws YarnRemoteException { throws IOException {
amContact = true; amContact = true;
@ -456,13 +458,13 @@ public GetJobReportResponse getJobReport(GetJobReportRequest request)
@Override @Override
public GetTaskReportResponse getTaskReport(GetTaskReportRequest request) public GetTaskReportResponse getTaskReport(GetTaskReportRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetTaskAttemptReportResponse getTaskAttemptReport( public GetTaskAttemptReportResponse getTaskAttemptReport(
GetTaskAttemptReportRequest request) throws YarnRemoteException { GetTaskAttemptReportRequest request) throws IOException {
return null; return null;
} }
@ -470,66 +472,66 @@ public GetTaskAttemptReportResponse getTaskAttemptReport(
public GetTaskAttemptCompletionEventsResponse public GetTaskAttemptCompletionEventsResponse
getTaskAttemptCompletionEvents( getTaskAttemptCompletionEvents(
GetTaskAttemptCompletionEventsRequest request) GetTaskAttemptCompletionEventsRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetTaskReportsResponse public GetTaskReportsResponse
getTaskReports(GetTaskReportsRequest request) getTaskReports(GetTaskReportsRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public GetDiagnosticsResponse public GetDiagnosticsResponse
getDiagnostics(GetDiagnosticsRequest request) getDiagnostics(GetDiagnosticsRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public KillJobResponse killJob(KillJobRequest request) public KillJobResponse killJob(KillJobRequest request)
throws YarnRemoteException { throws IOException {
return recordFactory.newRecordInstance(KillJobResponse.class); return recordFactory.newRecordInstance(KillJobResponse.class);
} }
@Override @Override
public KillTaskResponse killTask(KillTaskRequest request) public KillTaskResponse killTask(KillTaskRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public KillTaskAttemptResponse killTaskAttempt( public KillTaskAttemptResponse killTaskAttempt(
KillTaskAttemptRequest request) throws YarnRemoteException { KillTaskAttemptRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public FailTaskAttemptResponse failTaskAttempt( public FailTaskAttemptResponse failTaskAttempt(
FailTaskAttemptRequest request) throws YarnRemoteException { FailTaskAttemptRequest request) throws IOException {
return null; return null;
} }
@Override @Override
public org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenResponse getDelegationToken( public org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenResponse getDelegationToken(
org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenRequest request) org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetDelegationTokenRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenResponse renewDelegationToken( public org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenResponse renewDelegationToken(
org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenRequest request) org.apache.hadoop.mapreduce.v2.api.protocolrecords.RenewDelegationTokenRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
@Override @Override
public org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenResponse cancelDelegationToken( public org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenResponse cancelDelegationToken(
org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest request) org.apache.hadoop.mapreduce.v2.api.protocolrecords.CancelDelegationTokenRequest request)
throws YarnRemoteException { throws IOException {
return null; return null;
} }
} }

View File

@ -57,7 +57,6 @@
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException; import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.util.BuilderUtils; import org.apache.hadoop.yarn.util.BuilderUtils;
import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.Records;
import org.junit.Test; import org.junit.Test;
@ -103,7 +102,7 @@ public void testRemoteExceptionFromHistoryServer() throws Exception {
MRClientProtocol historyServerProxy = mock(MRClientProtocol.class); MRClientProtocol historyServerProxy = mock(MRClientProtocol.class);
when(historyServerProxy.getJobReport(getJobReportRequest())).thenThrow( when(historyServerProxy.getJobReport(getJobReportRequest())).thenThrow(
RPCUtil.getRemoteException("Job ID doesnot Exist")); new IOException("Job ID doesnot Exist"));
ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class); ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class);
when(rm.getApplicationReport(TypeConverter.toYarn(oldJobId).getAppId())) when(rm.getApplicationReport(TypeConverter.toYarn(oldJobId).getAppId()))
@ -199,8 +198,7 @@ public void testCountersFromHistoryServer() throws Exception {
} }
@Test @Test
public void testReconnectOnAMRestart() throws IOException, public void testReconnectOnAMRestart() throws IOException {
YarnRemoteException {
//test not applicable when AM not reachable //test not applicable when AM not reachable
//as instantiateAMProxy is not called at all //as instantiateAMProxy is not called at all
if(!isAMReachableFromClient) { if(!isAMReachableFromClient) {
@ -212,11 +210,15 @@ public void testReconnectOnAMRestart() throws IOException,
// RM returns AM1 url, null, null and AM2 url on invocations. // RM returns AM1 url, null, null and AM2 url on invocations.
// Nulls simulate the time when AM2 is in the process of restarting. // Nulls simulate the time when AM2 is in the process of restarting.
ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class); ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class);
try {
when(rmDelegate.getApplicationReport(jobId.getAppId())).thenReturn( when(rmDelegate.getApplicationReport(jobId.getAppId())).thenReturn(
getRunningApplicationReport("am1", 78)).thenReturn( getRunningApplicationReport("am1", 78)).thenReturn(
getRunningApplicationReport(null, 0)).thenReturn( getRunningApplicationReport(null, 0)).thenReturn(
getRunningApplicationReport(null, 0)).thenReturn( getRunningApplicationReport(null, 0)).thenReturn(
getRunningApplicationReport("am2", 90)); getRunningApplicationReport("am2", 90));
} catch (YarnRemoteException e) {
throw new IOException(e);
}
GetJobReportResponse jobReportResponse1 = mock(GetJobReportResponse.class); GetJobReportResponse jobReportResponse1 = mock(GetJobReportResponse.class);
when(jobReportResponse1.getJobReport()).thenReturn( when(jobReportResponse1.getJobReport()).thenReturn(
@ -267,7 +269,7 @@ public void testReconnectOnAMRestart() throws IOException,
} }
@Test @Test
public void testAMAccessDisabled() throws IOException, YarnRemoteException { public void testAMAccessDisabled() throws IOException {
//test only applicable when AM not reachable //test only applicable when AM not reachable
if(isAMReachableFromClient) { if(isAMReachableFromClient) {
return; return;
@ -278,11 +280,15 @@ public void testAMAccessDisabled() throws IOException, YarnRemoteException {
getJobReportResponseFromHistoryServer()); getJobReportResponseFromHistoryServer());
ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class); ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class);
try {
when(rmDelegate.getApplicationReport(jobId.getAppId())).thenReturn( when(rmDelegate.getApplicationReport(jobId.getAppId())).thenReturn(
getRunningApplicationReport("am1", 78)).thenReturn( getRunningApplicationReport("am1", 78)).thenReturn(
getRunningApplicationReport("am1", 78)).thenReturn( getRunningApplicationReport("am1", 78)).thenReturn(
getRunningApplicationReport("am1", 78)).thenReturn( getRunningApplicationReport("am1", 78)).thenReturn(
getFinishedApplicationReport()); getFinishedApplicationReport());
} catch (YarnRemoteException e) {
throw new IOException(e);
}
ClientServiceDelegate clientServiceDelegate = spy(getClientServiceDelegate( ClientServiceDelegate clientServiceDelegate = spy(getClientServiceDelegate(
historyServerProxy, rmDelegate)); historyServerProxy, rmDelegate));
@ -319,8 +325,7 @@ public void testAMAccessDisabled() throws IOException, YarnRemoteException {
} }
@Test @Test
public void testRMDownForJobStatusBeforeGetAMReport() throws IOException, public void testRMDownForJobStatusBeforeGetAMReport() throws IOException {
YarnRemoteException {
Configuration conf = new YarnConfiguration(); Configuration conf = new YarnConfiguration();
testRMDownForJobStatusBeforeGetAMReport(conf, testRMDownForJobStatusBeforeGetAMReport(conf,
MRJobConfig.DEFAULT_MR_CLIENT_MAX_RETRIES); MRJobConfig.DEFAULT_MR_CLIENT_MAX_RETRIES);
@ -328,7 +333,7 @@ public void testRMDownForJobStatusBeforeGetAMReport() throws IOException,
@Test @Test
public void testRMDownForJobStatusBeforeGetAMReportWithRetryTimes() public void testRMDownForJobStatusBeforeGetAMReportWithRetryTimes()
throws IOException, YarnRemoteException { throws IOException {
Configuration conf = new YarnConfiguration(); Configuration conf = new YarnConfiguration();
conf.setInt(MRJobConfig.MR_CLIENT_MAX_RETRIES, 2); conf.setInt(MRJobConfig.MR_CLIENT_MAX_RETRIES, 2);
testRMDownForJobStatusBeforeGetAMReport(conf, conf.getInt( testRMDownForJobStatusBeforeGetAMReport(conf, conf.getInt(
@ -338,7 +343,7 @@ public void testRMDownForJobStatusBeforeGetAMReportWithRetryTimes()
@Test @Test
public void testRMDownRestoreForJobStatusBeforeGetAMReport() public void testRMDownRestoreForJobStatusBeforeGetAMReport()
throws IOException, YarnRemoteException { throws IOException {
Configuration conf = new YarnConfiguration(); Configuration conf = new YarnConfiguration();
conf.setInt(MRJobConfig.MR_CLIENT_MAX_RETRIES, 3); conf.setInt(MRJobConfig.MR_CLIENT_MAX_RETRIES, 3);
@ -349,25 +354,32 @@ public void testRMDownRestoreForJobStatusBeforeGetAMReport()
when(historyServerProxy.getJobReport(any(GetJobReportRequest.class))) when(historyServerProxy.getJobReport(any(GetJobReportRequest.class)))
.thenReturn(getJobReportResponse()); .thenReturn(getJobReportResponse());
ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class); ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class);
try {
when(rmDelegate.getApplicationReport(jobId.getAppId())).thenThrow( when(rmDelegate.getApplicationReport(jobId.getAppId())).thenThrow(
new java.lang.reflect.UndeclaredThrowableException(new IOException( new java.lang.reflect.UndeclaredThrowableException(new IOException(
"Connection refuced1"))).thenThrow( "Connection refuced1"))).thenThrow(
new java.lang.reflect.UndeclaredThrowableException(new IOException( new java.lang.reflect.UndeclaredThrowableException(new IOException(
"Connection refuced2"))).thenReturn(getFinishedApplicationReport()); "Connection refuced2")))
.thenReturn(getFinishedApplicationReport());
ClientServiceDelegate clientServiceDelegate = new ClientServiceDelegate( ClientServiceDelegate clientServiceDelegate = new ClientServiceDelegate(
conf, rmDelegate, oldJobId, historyServerProxy); conf, rmDelegate, oldJobId, historyServerProxy);
JobStatus jobStatus = clientServiceDelegate.getJobStatus(oldJobId); JobStatus jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
verify(rmDelegate, times(3)).getApplicationReport(any(ApplicationId.class)); verify(rmDelegate, times(3)).getApplicationReport(
any(ApplicationId.class));
Assert.assertNotNull(jobStatus); Assert.assertNotNull(jobStatus);
} catch (YarnRemoteException e) {
throw new IOException(e);
}
} }
private void testRMDownForJobStatusBeforeGetAMReport(Configuration conf, private void testRMDownForJobStatusBeforeGetAMReport(Configuration conf,
int noOfRetries) throws YarnRemoteException, IOException { int noOfRetries) throws IOException {
conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME); conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
conf.setBoolean(MRJobConfig.JOB_AM_ACCESS_DISABLED, conf.setBoolean(MRJobConfig.JOB_AM_ACCESS_DISABLED,
!isAMReachableFromClient); !isAMReachableFromClient);
MRClientProtocol historyServerProxy = mock(MRClientProtocol.class); MRClientProtocol historyServerProxy = mock(MRClientProtocol.class);
ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class); ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class);
try {
when(rmDelegate.getApplicationReport(jobId.getAppId())).thenThrow( when(rmDelegate.getApplicationReport(jobId.getAppId())).thenThrow(
new java.lang.reflect.UndeclaredThrowableException(new IOException( new java.lang.reflect.UndeclaredThrowableException(new IOException(
"Connection refuced1"))).thenThrow( "Connection refuced1"))).thenThrow(
@ -385,6 +397,9 @@ private void testRMDownForJobStatusBeforeGetAMReport(Configuration conf,
} }
verify(rmDelegate, times(noOfRetries)).getApplicationReport( verify(rmDelegate, times(noOfRetries)).getApplicationReport(
any(ApplicationId.class)); any(ApplicationId.class));
} catch (YarnRemoteException e) {
throw new IOException(e);
}
} }
private GetJobReportRequest getJobReportRequest() { private GetJobReportRequest getJobReportRequest() {
@ -429,10 +444,13 @@ private ApplicationReport getRunningApplicationReport(String host, int port) {
"N/A", 0.0f); "N/A", 0.0f);
} }
private ResourceMgrDelegate getRMDelegate() throws YarnRemoteException, private ResourceMgrDelegate getRMDelegate() throws IOException {
IOException {
ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class); ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class);
try {
when(rm.getApplicationReport(jobId.getAppId())).thenReturn(null); when(rm.getApplicationReport(jobId.getAppId())).thenReturn(null);
} catch (YarnRemoteException e) {
throw new IOException(e);
}
return rm; return rm;
} }

View File

@ -48,19 +48,21 @@ public class TestResourceMgrDelegate {
/** /**
* Tests that getRootQueues makes a request for the (recursive) child queues * Tests that getRootQueues makes a request for the (recursive) child queues
* @throws YarnRemoteException
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testGetRootQueues() throws IOException, InterruptedException, public void testGetRootQueues() throws IOException, InterruptedException {
YarnRemoteException {
final ClientRMProtocol applicationsManager = Mockito.mock(ClientRMProtocol.class); final ClientRMProtocol applicationsManager = Mockito.mock(ClientRMProtocol.class);
GetQueueInfoResponse response = Mockito.mock(GetQueueInfoResponse.class); GetQueueInfoResponse response = Mockito.mock(GetQueueInfoResponse.class);
org.apache.hadoop.yarn.api.records.QueueInfo queueInfo = org.apache.hadoop.yarn.api.records.QueueInfo queueInfo =
Mockito.mock(org.apache.hadoop.yarn.api.records.QueueInfo.class); Mockito.mock(org.apache.hadoop.yarn.api.records.QueueInfo.class);
Mockito.when(response.getQueueInfo()).thenReturn(queueInfo); Mockito.when(response.getQueueInfo()).thenReturn(queueInfo);
try {
Mockito.when(applicationsManager.getQueueInfo(Mockito.any( Mockito.when(applicationsManager.getQueueInfo(Mockito.any(
GetQueueInfoRequest.class))).thenReturn(response); GetQueueInfoRequest.class))).thenReturn(response);
} catch (YarnRemoteException e) {
throw new IOException(e);
}
ResourceMgrDelegate delegate = new ResourceMgrDelegate( ResourceMgrDelegate delegate = new ResourceMgrDelegate(
new YarnConfiguration()) { new YarnConfiguration()) {
@ -73,8 +75,12 @@ public synchronized void start() {
ArgumentCaptor<GetQueueInfoRequest> argument = ArgumentCaptor<GetQueueInfoRequest> argument =
ArgumentCaptor.forClass(GetQueueInfoRequest.class); ArgumentCaptor.forClass(GetQueueInfoRequest.class);
try {
Mockito.verify(applicationsManager).getQueueInfo( Mockito.verify(applicationsManager).getQueueInfo(
argument.capture()); argument.capture());
} catch (YarnRemoteException e) {
throw new IOException(e);
}
Assert.assertTrue("Children of root queue not requested", Assert.assertTrue("Children of root queue not requested",
argument.getValue().getIncludeChildQueues()); argument.getValue().getIncludeChildQueues());

View File

@ -174,6 +174,7 @@ private void testKillTask(Job job, Configuration conf) throws Exception {
runTool(conf, jc, new String[] { "-kill-task", taid.toString() }, out); runTool(conf, jc, new String[] { "-kill-task", taid.toString() }, out);
fail(" this task should be killed"); fail(" this task should be killed");
} catch (IOException e) { } catch (IOException e) {
System.out.println(e);
// task completed // task completed
assertTrue(e.getMessage().contains("_0001_m_000000_1")); assertTrue(e.getMessage().contains("_0001_m_000000_1"));
} }

View File

@ -22,7 +22,6 @@
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
@ -48,7 +47,6 @@
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod; import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
import org.apache.hadoop.yarn.api.records.DelegationToken; import org.apache.hadoop.yarn.api.records.DelegationToken;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.util.ProtoUtils; import org.apache.hadoop.yarn.util.ProtoUtils;
import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.Records;
@ -62,8 +60,7 @@ public class TestJHSSecurity {
private static final Log LOG = LogFactory.getLog(TestJHSSecurity.class); private static final Log LOG = LogFactory.getLog(TestJHSSecurity.class);
@Test @Test
public void testDelegationToken() throws IOException, InterruptedException, public void testDelegationToken() throws IOException, InterruptedException {
YarnRemoteException {
Logger rootLogger = LogManager.getRootLogger(); Logger rootLogger = LogManager.getRootLogger();
rootLogger.setLevel(Level.DEBUG); rootLogger.setLevel(Level.DEBUG);
@ -124,7 +121,7 @@ protected JHSDelegationTokenSecretManager createJHSSecretManager(
jobReportRequest.setJobId(MRBuilderUtils.newJobId(123456, 1, 1)); jobReportRequest.setJobId(MRBuilderUtils.newJobId(123456, 1, 1));
try { try {
clientUsingDT.getJobReport(jobReportRequest); clientUsingDT.getJobReport(jobReportRequest);
} catch (YarnRemoteException e) { } catch (IOException e) {
Assert.assertEquals("Unknown job job_123456_0001", e.getMessage()); Assert.assertEquals("Unknown job job_123456_0001", e.getMessage());
} }
@ -147,7 +144,7 @@ protected JHSDelegationTokenSecretManager createJHSSecretManager(
// Valid token because of renewal. // Valid token because of renewal.
try { try {
clientUsingDT.getJobReport(jobReportRequest); clientUsingDT.getJobReport(jobReportRequest);
} catch (UndeclaredThrowableException e) { } catch (IOException e) {
Assert.assertEquals("Unknown job job_123456_0001", e.getMessage()); Assert.assertEquals("Unknown job job_123456_0001", e.getMessage());
} }
@ -161,7 +158,7 @@ protected JHSDelegationTokenSecretManager createJHSSecretManager(
try { try {
clientUsingDT.getJobReport(jobReportRequest); clientUsingDT.getJobReport(jobReportRequest);
fail("Should not have succeeded with an expired token"); fail("Should not have succeeded with an expired token");
} catch (UndeclaredThrowableException e) { } catch (IOException e) {
assertTrue(e.getCause().getMessage().contains("is expired")); assertTrue(e.getCause().getMessage().contains("is expired"));
} }
@ -183,7 +180,7 @@ protected JHSDelegationTokenSecretManager createJHSSecretManager(
try { try {
clientUsingDT.getJobReport(jobReportRequest); clientUsingDT.getJobReport(jobReportRequest);
} catch (UndeclaredThrowableException e) { } catch (IOException e) {
fail("Unexpected exception" + e); fail("Unexpected exception" + e);
} }
cancelDelegationToken(loggedInUser, hsService, token); cancelDelegationToken(loggedInUser, hsService, token);
@ -200,7 +197,7 @@ protected JHSDelegationTokenSecretManager createJHSSecretManager(
try { try {
clientUsingDT.getJobReport(jobReportRequest); clientUsingDT.getJobReport(jobReportRequest);
fail("Should not have succeeded with a cancelled delegation token"); fail("Should not have succeeded with a cancelled delegation token");
} catch (UndeclaredThrowableException e) { } catch (IOException e) {
} }
@ -219,7 +216,7 @@ private DelegationToken getDelegationToken(
DelegationToken token = loggedInUser DelegationToken token = loggedInUser
.doAs(new PrivilegedExceptionAction<DelegationToken>() { .doAs(new PrivilegedExceptionAction<DelegationToken>() {
@Override @Override
public DelegationToken run() throws YarnRemoteException { public DelegationToken run() throws IOException {
GetDelegationTokenRequest request = Records GetDelegationTokenRequest request = Records
.newRecord(GetDelegationTokenRequest.class); .newRecord(GetDelegationTokenRequest.class);
request.setRenewer(renewerString); request.setRenewer(renewerString);
@ -236,7 +233,7 @@ private long renewDelegationToken(final UserGroupInformation loggedInUser,
long nextExpTime = loggedInUser.doAs(new PrivilegedExceptionAction<Long>() { long nextExpTime = loggedInUser.doAs(new PrivilegedExceptionAction<Long>() {
@Override @Override
public Long run() throws YarnRemoteException { public Long run() throws IOException {
RenewDelegationTokenRequest request = Records RenewDelegationTokenRequest request = Records
.newRecord(RenewDelegationTokenRequest.class); .newRecord(RenewDelegationTokenRequest.class);
request.setDelegationToken(dToken); request.setDelegationToken(dToken);
@ -252,7 +249,7 @@ private void cancelDelegationToken(final UserGroupInformation loggedInUser,
loggedInUser.doAs(new PrivilegedExceptionAction<Void>() { loggedInUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override @Override
public Void run() throws YarnRemoteException { public Void run() throws IOException {
CancelDelegationTokenRequest request = Records CancelDelegationTokenRequest request = Records
.newRecord(CancelDelegationTokenRequest.class); .newRecord(CancelDelegationTokenRequest.class);
request.setDelegationToken(dToken); request.setDelegationToken(dToken);

View File

@ -45,7 +45,6 @@
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.util.BuilderUtils; import org.apache.hadoop.yarn.util.BuilderUtils;
@ -111,7 +110,7 @@ public void tearDown() {
@Test @Test
public void testJobHistoryData() throws IOException, InterruptedException, public void testJobHistoryData() throws IOException, InterruptedException,
AvroRemoteException, ClassNotFoundException, YarnRemoteException { AvroRemoteException, ClassNotFoundException {
if (!(new File(MiniMRYarnCluster.APPJAR)).exists()) { if (!(new File(MiniMRYarnCluster.APPJAR)).exists()) {
LOG.info("MRAppJar " + MiniMRYarnCluster.APPJAR LOG.info("MRAppJar " + MiniMRYarnCluster.APPJAR
+ " not found. Not running test."); + " not found. Not running test.");