private void validateStartTime() { if (startedTimeBegin < 0) { throw new BadRequestException("startedTimeBegin must be greater than 0"); } if (startedTimeEnd < 0) { throw new BadRequestException("startedTimeEnd must be greater than 0"); } if (startedTimeBegin > startedTimeEnd) { throw new BadRequestException( "startedTimeEnd must be greater than startTimeBegin"); } }
getUser(req)); } catch (NumberFormatException e) { throw (BadRequestException)new BadRequestException( "windowStart, windowEnd or limit is not a numeric value.") .initCause(e); } catch (Exception e) { LOG.error("Error getting entity timelines", e);
private void validateFinishTime() { if (finishTimeBegin < 0) { throw new BadRequestException("finishTimeBegin must be greater than 0"); } if (finishTimeEnd < 0) { throw new BadRequestException("finishTimeEnd must be greater than 0"); } if (finishTimeBegin > finishTimeEnd) { throw new BadRequestException( "finishTimeEnd must be greater than finishTimeBegin"); } }
private long parseLongValue(String strValue, String queryName) { try { return Long.parseLong(strValue); } catch (NumberFormatException e) { throw new BadRequestException(queryName + " value must be a number!"); } }
private Token<RMDelegationTokenIdentifier> extractToken( HttpServletRequest request) { String encodedToken = request.getHeader(DELEGATION_TOKEN_HEADER); if (encodedToken == null) { String msg = "Header '" + DELEGATION_TOKEN_HEADER + "' containing encoded token not found"; throw new BadRequestException(msg); } return extractToken(encodedToken); }
private Token<RMDelegationTokenIdentifier> extractToken( HttpServletRequest request) { String encodedToken = request.getHeader(DELEGATION_TOKEN_HEADER); if (encodedToken == null) { String msg = "Header '" + DELEGATION_TOKEN_HEADER + "' containing encoded token not found"; throw new BadRequestException(msg); } return extractToken(encodedToken); }
private void validateLimit() { if (limit != null) { limitNumber = parseLongValue(limit, "limit"); if (limitNumber <= 0) { throw new BadRequestException("limit value must be greater then 0"); } } }
private Token<RMDelegationTokenIdentifier> extractToken( HttpServletRequest request) { String encodedToken = request.getHeader(DELEGATION_TOKEN_HEADER); if (encodedToken == null) { String msg = "Header '" + DELEGATION_TOKEN_HEADER + "' containing encoded token not found"; throw new BadRequestException(msg); } return extractToken(encodedToken); }
private void validateQueueExists(ResourceManager rm, String queueQuery) { ResourceScheduler rs = rm.getResourceScheduler(); if (rs instanceof CapacityScheduler) { CapacityScheduler cs = (CapacityScheduler) rs; try { cs.getQueueInfo(queueQuery, false, false); } catch (IOException e) { throw new BadRequestException(e.getMessage()); } } }
private ApplicationTimeoutType parseTimeoutType(String type) { try { // enum string is in the uppercase return ApplicationTimeoutType .valueOf(StringUtils.toUpperCase(type.trim())); } catch (RuntimeException e) { ApplicationTimeoutType[] typeArray = ApplicationTimeoutType.values(); String allAppTimeoutTypes = Arrays.toString(typeArray); throw new BadRequestException("Invalid application-state " + type.trim() + " specified. It should be one of " + allAppTimeoutTypes); } }
private Token<RMDelegationTokenIdentifier> extractToken(String encodedToken) { Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(); try { token.decodeFromUrlString(encodedToken); } catch (Exception ie) { String msg = "Could not decode encoded token"; throw new BadRequestException(msg); } return token; }
/** * Initial DeSelectFields with unselected fields. * @param unselectedFields a set of unselected field. */ public void initFields(Set<String> unselectedFields) { if (unselectedFields == null) { return; } for (String field : unselectedFields) { if (!field.trim().isEmpty()) { String[] literalsArray = field.split(","); for (String literals : literalsArray) { if (literals != null && !literals.trim().isEmpty()) { DeSelectType type = DeSelectType.obtainType(literals); if (type == null) { LOG.warn("Invalid deSelects string " + literals.trim()); DeSelectType[] typeArray = DeSelectType.values(); String allSuppportLiterals = Arrays.toString(typeArray); throw new BadRequestException("Invalid deSelects string " + literals.trim() + " specified. It should be one of " + allSuppportLiterals); } else { this.types.add(type); } } } } } }
private Token<RMDelegationTokenIdentifier> extractToken(String encodedToken) { Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(); try { token.decodeFromUrlString(encodedToken); } catch (Exception ie) { String msg = "Could not decode encoded token"; throw new BadRequestException(msg); } return token; } }
private Token<RMDelegationTokenIdentifier> extractToken(String encodedToken) { Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(); try { token.decodeFromUrlString(encodedToken); } catch (Exception ie) { String msg = "Could not decode encoded token"; throw new BadRequestException(msg); } return token; } }
YarnApplicationState.values(); String allAppStates = Arrays.toString(stateArray); throw new BadRequestException( "Invalid application-state " + paramStr.trim() + " specified. It should be one of " + allAppStates);
YarnApplicationState.values(); String allAppStates = Arrays.toString(stateArray); throw new BadRequestException("Invalid application-state " + paramStr.trim() + " specified. It should be one of " + allAppStates);
/** * Return a list of domains of the given owner. */ @GET @Path("/domain") @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) public TimelineDomains getDomains( @Context HttpServletRequest req, @Context HttpServletResponse res, @QueryParam("owner") String owner) { init(res); owner = parseStr(owner); UserGroupInformation callerUGI = getUser(req); if (owner == null || owner.length() == 0) { if (callerUGI == null) { throw new BadRequestException("Domain owner is not specified."); } else { // By default it's going to list the caller's domains owner = callerUGI.getShortUserName(); } } try { return timelineDataManager.getDomains(owner, callerUGI); } catch (Exception e) { LOG.error("Error getting domains", e); throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } }
YarnApplicationState.values(); String allAppStates = Arrays.toString(stateArray); throw new BadRequestException( "Invalid application-state " + paramStr.trim() + " specified. It should be one of " + allAppStates);
/** * Return a list of domains of the given owner. */ @GET @Path("/domain") @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 /* , MediaType.APPLICATION_XML */}) public TimelineDomains getDomains( @Context HttpServletRequest req, @Context HttpServletResponse res, @QueryParam("owner") String owner) { init(res); owner = parseStr(owner); UserGroupInformation callerUGI = getUser(req); if (owner == null || owner.length() == 0) { if (callerUGI == null) { throw new BadRequestException("Domain owner is not specified."); } else { // By default it's going to list the caller's domains owner = callerUGI.getShortUserName(); } } try { return timelineDataManager.getDomains(owner, callerUGI); } catch (Exception e) { LOG.error("Error getting domains", e); throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } }
public static ApplicationId parseApplicationId(RecordFactory recordFactory, String appId) { if (appId == null || appId.isEmpty()) { throw new NotFoundException("appId, " + appId + ", is empty or null"); } ApplicationId aid = null; try { aid = ApplicationId.fromString(appId); } catch (Exception e) { throw new BadRequestException(e); } if (aid == null) { throw new NotFoundException("app with id " + appId + " not found"); } return aid; }