@Override public KillTaskAttemptResponseProto killTaskAttempt(RpcController controller, KillTaskAttemptRequestProto proto) throws ServiceException { KillTaskAttemptRequest request = new KillTaskAttemptRequestPBImpl(proto); try { KillTaskAttemptResponse response = real.killTaskAttempt(request); return ((KillTaskAttemptResponsePBImpl)response).getProto(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public KillTaskAttemptResponse killTaskAttempt(KillTaskAttemptRequest request) throws IOException { KillTaskAttemptRequestProto requestProto = ((KillTaskAttemptRequestPBImpl)request).getProto(); try { return new KillTaskAttemptResponsePBImpl(proxy.killTaskAttempt(null, requestProto)); } catch (ServiceException e) { throw unwrapAndThrowException(e); } }
protected Response killJobTaskAttempt(TaskAttempt ta, UserGroupInformation callerUGI, HttpServletRequest hsr) throws IOException, InterruptedException { Preconditions.checkNotNull(ta, "ta cannot be null"); String userName = callerUGI.getUserName(); final TaskAttemptId attemptId = ta.getID(); try { callerUGI .doAs(new PrivilegedExceptionAction<KillTaskAttemptResponse>() { @Override public KillTaskAttemptResponse run() throws IOException, YarnException { KillTaskAttemptRequest req = new KillTaskAttemptRequestPBImpl(); req.setTaskAttemptId(attemptId); return service.forceKillTaskAttempt(req); } }); } catch (UndeclaredThrowableException ue) { // if the root cause is a permissions issue // bubble that up to the user if (ue.getCause() instanceof YarnException) { YarnException ye = (YarnException) ue.getCause(); if (ye.getCause() instanceof AccessControlException) { String taId = attemptId.toString(); String msg = "Unauthorized attempt to kill task attempt " + taId + " by remote user " + userName; return Response.status(Status.FORBIDDEN).entity(msg).build(); } else { throw ue; } } else { throw ue; } } JobTaskAttemptState ret = new JobTaskAttemptState(); ret.setState(TaskAttemptState.KILLED.toString()); return Response.status(Status.OK).entity(ret).build(); }