當前位置: 首頁>>代碼示例>>Java>>正文


Java YarnException.getCause方法代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.exceptions.YarnException.getCause方法的典型用法代碼示例。如果您正苦於以下問題:Java YarnException.getCause方法的具體用法?Java YarnException.getCause怎麽用?Java YarnException.getCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.yarn.exceptions.YarnException的用法示例。


在下文中一共展示了YarnException.getCause方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: killApp

import org.apache.hadoop.yarn.exceptions.YarnException; //導入方法依賴的package包/類
protected Response killApp(RMApp app, UserGroupInformation callerUGI,
    HttpServletRequest hsr) throws IOException, InterruptedException {

  if (app == null) {
    throw new IllegalArgumentException("app cannot be null");
  }
  String userName = callerUGI.getUserName();
  final ApplicationId appid = app.getApplicationId();
  KillApplicationResponse resp = null;
  try {
    resp =
        callerUGI
          .doAs(new PrivilegedExceptionAction<KillApplicationResponse>() {
            @Override
            public KillApplicationResponse run() throws IOException,
                YarnException {
              KillApplicationRequest req =
                  KillApplicationRequest.newInstance(appid);
              return rm.getClientRMService().forceKillApplication(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 appId = app.getApplicationId().toString();
        String msg =
            "Unauthorized attempt to kill appid " + appId
                + " by remote user " + userName;
        return Response.status(Status.FORBIDDEN).entity(msg).build();
      } else {
        throw ue;
      }
    } else {
      throw ue;
    }
  }

  AppState ret = new AppState();
  ret.setState(app.getState().toString());

  if (resp.getIsKillCompleted()) {
    RMAuditLogger.logSuccess(userName, AuditConstants.KILL_APP_REQUEST,
      "RMWebService", app.getApplicationId());
  } else {
    return Response.status(Status.ACCEPTED).entity(ret)
      .header(HttpHeaders.LOCATION, hsr.getRequestURL()).build();
  }
  return Response.status(Status.OK).entity(ret).build();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:53,代碼來源:RMWebServices.java

示例2: moveApp

import org.apache.hadoop.yarn.exceptions.YarnException; //導入方法依賴的package包/類
protected Response moveApp(RMApp app, UserGroupInformation callerUGI,
    String targetQueue) throws IOException, InterruptedException {

  if (app == null) {
    throw new IllegalArgumentException("app cannot be null");
  }
  String userName = callerUGI.getUserName();
  final ApplicationId appid = app.getApplicationId();
  final String reqTargetQueue = targetQueue;
  try {
    callerUGI
      .doAs(new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws IOException,
            YarnException {
          MoveApplicationAcrossQueuesRequest req =
              MoveApplicationAcrossQueuesRequest.newInstance(appid,
                reqTargetQueue);
          rm.getClientRMService().moveApplicationAcrossQueues(req);
          return null;
        }
      });
  } 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 appId = app.getApplicationId().toString();
        String msg =
            "Unauthorized attempt to move appid " + appId
                + " by remote user " + userName;
        return Response.status(Status.FORBIDDEN).entity(msg).build();
      } else if (ye.getMessage().startsWith("App in")
          && ye.getMessage().endsWith("state cannot be moved.")) {
        return Response.status(Status.BAD_REQUEST).entity(ye.getMessage())
          .build();
      } else {
        throw ue;
      }
    } else {
      throw ue;
    }
  }

  AppQueue ret = new AppQueue();
  ret.setQueue(app.getQueue());
  return Response.status(Status.OK).entity(ret).build();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:50,代碼來源:RMWebServices.java


注:本文中的org.apache.hadoop.yarn.exceptions.YarnException.getCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。