当前位置: 首页>>代码示例>>Java>>正文


Java UndeclaredThrowableException.getCause方法代码示例

本文整理汇总了Java中java.lang.reflect.UndeclaredThrowableException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java UndeclaredThrowableException.getCause方法的具体用法?Java UndeclaredThrowableException.getCause怎么用?Java UndeclaredThrowableException.getCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.UndeclaredThrowableException的用法示例。


在下文中一共展示了UndeclaredThrowableException.getCause方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: submitApplication

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
public static void submitApplication(
    ApplicationSubmissionContext appContext, UserDescriptor user) throws Throwable {
  UserGroupInformation ugi =
      UserGroupInformation.createRemoteUser(user.getName());
  // Need to start a new YarnClient for a new UGI, since its internal Hadoop RPC
  // reuse the UGI after YarnClient.start().
  try {
    ugi.doAs((PrivilegedExceptionAction<Void>) () -> {
      YarnClient yarnClient = YarnClient.createYarnClient();
      yarnClient.init(conf);
      yarnClient.start();
      yarnClient.submitApplication(appContext);
      yarnClient.stop();
      return null;
    });
  } catch (UndeclaredThrowableException e) {
    throw e.getCause();
  }
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:20,代码来源:HadoopUtils.java

示例2: unregisterAppAttempt

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  if (ugi == null) {
    ugi =  UserGroupInformation.createRemoteUser(attemptId.toString());
    Token<AMRMTokenIdentifier> token =
        context.getRMApps()
            .get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    ugi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        amRMProtocol.finishApplicationMaster(req);
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:MockAM.java

示例3: startTimelineClient

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
@VisibleForTesting
void startTimelineClient(final Configuration conf)
    throws YarnException, IOException, InterruptedException {
  try {
    appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
            YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
          // Creating the Timeline Client
          timelineClient = TimelineClient.createTimelineClient();
          timelineClient.init(conf);
          timelineClient.start();
        } else {
          timelineClient = null;
          LOG.warn("Timeline service is not enabled");
        }
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw new YarnException(e.getCause());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:ApplicationMaster.java

示例4: doPosting

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
private ClientResponse doPosting(final Object obj, final String path)
    throws IOException, YarnException {
  ClientResponse resp;
  try {
    resp = authUgi.doAs(new PrivilegedExceptionAction<ClientResponse>() {
      @Override
      public ClientResponse run() throws Exception {
        return doPostingObject(obj, path);
      }
    });
  } catch (UndeclaredThrowableException e) {
      throw new IOException(e.getCause());
  } catch (InterruptedException ie) {
    throw new IOException(ie);
  }
  if (resp == null ||
      resp.getClientResponseStatus() != ClientResponse.Status.OK) {
    String msg =
        "Failed to get the response from the timeline server.";
    LOG.error(msg);
    if (LOG.isDebugEnabled() && resp != null) {
      String output = resp.getEntity(String.class);
      LOG.debug("HTTP error code: " + resp.getStatus()
          + " Server response : \n" + output);
    }
    throw new YarnException(msg);
  }
  return resp;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TimelineClientImpl.java

示例5: getHttpURLConnection

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
@Override
public HttpURLConnection getHttpURLConnection(final URL url) throws IOException {
  authUgi.checkTGTAndReloginFromKeytab();
  try {
    return new DelegationTokenAuthenticatedURL(
        authenticator, connConfigurator).openConnection(url, token,
          doAsUser);
  } catch (UndeclaredThrowableException e) {
    throw new IOException(e.getCause());
  } catch (AuthenticationException ae) {
    throw new IOException(ae);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TimelineClientImpl.java

示例6: registerAppAttempt

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
public RegisterApplicationMasterResponse registerAppAttempt(boolean wait)
    throws Exception {
  if (wait) {
    waitForState(RMAppAttemptState.LAUNCHED);
  }
  responseId = 0;
  final RegisterApplicationMasterRequest req =
      Records.newRecord(RegisterApplicationMasterRequest.class);
  req.setHost("");
  req.setRpcPort(1);
  req.setTrackingUrl("");
  if (ugi == null) {
    ugi = UserGroupInformation.createRemoteUser(
        attemptId.toString());
    Token<AMRMTokenIdentifier> token =
        context.getRMApps().get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    return ugi
      .doAs(
          new PrivilegedExceptionAction<RegisterApplicationMasterResponse>() {
        @Override
        public RegisterApplicationMasterResponse run() throws Exception {
          return amRMProtocol.registerApplicationMaster(req);
        }
      });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:MockAM.java

示例7: doAllocateAs

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
public AllocateResponse doAllocateAs(UserGroupInformation ugi,
    final AllocateRequest req) throws Exception {
  req.setResponseId(++responseId);
  try {
    return ugi.doAs(new PrivilegedExceptionAction<AllocateResponse>() {
      @Override
      public AllocateResponse run() throws Exception {
        return amRMProtocol.allocate(req);
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:MockAM.java

示例8: killApp

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的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

示例9: moveApp

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的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

示例10: submitApplication

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
/**
 * Function to submit an app to the RM
 * 
 * @param newApp
 *          structure containing information to construct the
 *          ApplicationSubmissionContext
 * @param hsr
 *          the servlet request
 * @return Response containing the status code
 * @throws AuthorizationException
 * @throws IOException
 * @throws InterruptedException
 */
@POST
@Path("/apps")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response submitApplication(ApplicationSubmissionContextInfo newApp,
    @Context HttpServletRequest hsr) throws AuthorizationException,
    IOException, InterruptedException {

  init();
  UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
  if (callerUGI == null) {
    throw new AuthorizationException("Unable to obtain user name, "
        + "user not authenticated");
  }

  if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
    String msg = "The default static user cannot carry out this operation.";
    return Response.status(Status.FORBIDDEN).entity(msg).build();
  }

  ApplicationSubmissionContext appContext =
      createAppSubmissionContext(newApp);
  final SubmitApplicationRequest req =
      SubmitApplicationRequest.newInstance(appContext);

  try {
    callerUGI
      .doAs(new PrivilegedExceptionAction<SubmitApplicationResponse>() {
        @Override
        public SubmitApplicationResponse run() throws IOException,
            YarnException {
          return rm.getClientRMService().submitApplication(req);
        }
      });
  } catch (UndeclaredThrowableException ue) {
    if (ue.getCause() instanceof YarnException) {
      throw new BadRequestException(ue.getCause().getMessage());
    }
    LOG.info("Submit app request failed", ue);
    throw ue;
  }

  String url = hsr.getRequestURL() + "/" + newApp.getApplicationId();
  return Response.status(Status.ACCEPTED).header(HttpHeaders.LOCATION, url)
    .build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:60,代码来源:RMWebServices.java

示例11: renewDelegationToken

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
private Response renewDelegationToken(DelegationToken tokenData,
    HttpServletRequest hsr, UserGroupInformation callerUGI)
    throws AuthorizationException, IOException, InterruptedException,
    Exception {

  Token<RMDelegationTokenIdentifier> token =
      extractToken(tokenData.getToken());

  org.apache.hadoop.yarn.api.records.Token dToken =
      BuilderUtils.newDelegationToken(token.getIdentifier(), token.getKind()
        .toString(), token.getPassword(), token.getService().toString());
  final RenewDelegationTokenRequest req =
      RenewDelegationTokenRequest.newInstance(dToken);

  RenewDelegationTokenResponse resp;
  try {
    resp =
        callerUGI
          .doAs(new PrivilegedExceptionAction<RenewDelegationTokenResponse>() {
            @Override
            public RenewDelegationTokenResponse run() throws IOException,
                YarnException {
              return rm.getClientRMService().renewDelegationToken(req);
            }
          });
  } catch (UndeclaredThrowableException ue) {
    if (ue.getCause() instanceof YarnException) {
      if (ue.getCause().getCause() instanceof InvalidToken) {
        throw new BadRequestException(ue.getCause().getCause().getMessage());
      } else if (ue.getCause().getCause() instanceof org.apache.hadoop.security.AccessControlException) {
        return Response.status(Status.FORBIDDEN)
          .entity(ue.getCause().getCause().getMessage()).build();
      }
      LOG.info("Renew delegation token request failed", ue);
      throw ue;
    }
    LOG.info("Renew delegation token request failed", ue);
    throw ue;
  } catch (Exception e) {
    LOG.info("Renew delegation token request failed", e);
    throw e;
  }
  long renewTime = resp.getNextExpirationTime();

  DelegationToken respToken = new DelegationToken();
  respToken.setNextExpirationTime(renewTime);
  return Response.status(Status.OK).entity(respToken).build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:RMWebServices.java

示例12: cancelDelegationToken

import java.lang.reflect.UndeclaredThrowableException; //导入方法依赖的package包/类
@DELETE
@Path("/delegation-token")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response cancelDelegationToken(@Context HttpServletRequest hsr)
    throws AuthorizationException, IOException, InterruptedException,
    Exception {

  init();
  UserGroupInformation callerUGI;
  try {
    callerUGI = createKerberosUserGroupInformation(hsr);
  } catch (YarnException ye) {
    return Response.status(Status.FORBIDDEN).entity(ye.getMessage()).build();
  }

  Token<RMDelegationTokenIdentifier> token = extractToken(hsr);

  org.apache.hadoop.yarn.api.records.Token dToken =
      BuilderUtils.newDelegationToken(token.getIdentifier(), token.getKind()
        .toString(), token.getPassword(), token.getService().toString());
  final CancelDelegationTokenRequest req =
      CancelDelegationTokenRequest.newInstance(dToken);

  try {
    callerUGI
      .doAs(new PrivilegedExceptionAction<CancelDelegationTokenResponse>() {
        @Override
        public CancelDelegationTokenResponse run() throws IOException,
            YarnException {
          return rm.getClientRMService().cancelDelegationToken(req);
        }
      });
  } catch (UndeclaredThrowableException ue) {
    if (ue.getCause() instanceof YarnException) {
      if (ue.getCause().getCause() instanceof InvalidToken) {
        throw new BadRequestException(ue.getCause().getCause().getMessage());
      } else if (ue.getCause().getCause() instanceof org.apache.hadoop.security.AccessControlException) {
        return Response.status(Status.FORBIDDEN)
          .entity(ue.getCause().getCause().getMessage()).build();
      }
      LOG.info("Renew delegation token request failed", ue);
      throw ue;
    }
    LOG.info("Renew delegation token request failed", ue);
    throw ue;
  } catch (Exception e) {
    LOG.info("Renew delegation token request failed", e);
    throw e;
  }

  return Response.status(Status.OK).build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:53,代码来源:RMWebServices.java


注:本文中的java.lang.reflect.UndeclaredThrowableException.getCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。