本文整理汇总了Java中org.apache.hadoop.yarn.webapp.RemoteExceptionData类的典型用法代码示例。如果您正苦于以下问题:Java RemoteExceptionData类的具体用法?Java RemoteExceptionData怎么用?Java RemoteExceptionData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteExceptionData类属于org.apache.hadoop.yarn.webapp包,在下文中一共展示了RemoteExceptionData类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toResponse
import org.apache.hadoop.yarn.webapp.RemoteExceptionData; //导入依赖的package包/类
@Override
public Response toResponse(Exception e) {
// Don't catch this as filter forward on 404
// (ServletContainer.FEATURE_FILTER_FORWARD_ON_404)
// won't work and the web UI won't work!
if (e instanceof com.sun.jersey.api.NotFoundException) {
return ((com.sun.jersey.api.NotFoundException) e).getResponse();
}
// clear content type
response.setContentType(null);
// Map response status
String logPrefix = "Http request failed due to: ";
final int statusCode;
if (e instanceof NotFoundException) {
LOGGER.logInfo(e, logPrefix + "Not Found");
statusCode = HttpStatus.SC_NOT_FOUND;
} else if (e instanceof BadRequestException ||
e instanceof JsonProcessingException ||
e instanceof WebApplicationException) {
LOGGER.logInfo(e, logPrefix + "Bad Request");
statusCode = HttpStatus.SC_BAD_REQUEST;
} else if (e instanceof ThrottledRequestException) {
LOGGER.logInfo(e, logPrefix + "Throttled Request");
statusCode = WebCommon.SC_TOO_MANY_REQUESTS;
} else {
LOGGER.logWarning(e, logPrefix + "Service Unavailable");
statusCode = HttpStatus.SC_SERVICE_UNAVAILABLE;
}
// let jaxb handle marshalling data out in the same format requested
RemoteExceptionData exception = new RemoteExceptionData(
e.getClass().getSimpleName(),
StringUtils.stringifyException(e),
e.getClass().getName());
return Response.status(statusCode).entity(exception)
.build();
}