/** * Valid if a node label expression specified on container request is valid or * not * * @param containerRequest */ private void checkNodeLabelExpression(T containerRequest) { String exp = containerRequest.getNodeLabelExpression(); if (null == exp || exp.isEmpty()) { return; } // Don't support specifying > 1 node labels in a node label expression now if (exp.contains("&&") || exp.contains("||")) { throw new InvalidContainerRequestException( "Cannot specify more than one node label" + " in a single node label expression"); } }
/** * Valid if a node label expression specified on container request is valid or * not * * @param containerRequest */ private void checkNodeLabelExpression(T containerRequest) { String exp = containerRequest.getNodeLabelExpression(); if (null == exp || exp.isEmpty()) { return; } // Don't support specifying >= 2 node labels in a node label expression now if (exp.contains("&&") || exp.contains("||")) { throw new InvalidContainerRequestException( "Cannot specify more than two node labels" + " in a single node label expression"); } }
/** * Valid if a node label expression specified on container request is valid or * not * * @param containerRequest */ private void checkNodeLabelExpression(T containerRequest) { String exp = containerRequest.getNodeLabelExpression(); if (null == exp || exp.isEmpty()) { return; } // Don't support specifying >= 2 node labels in a node label expression now if (exp.contains("&&") || exp.contains("||")) { throw new InvalidContainerRequestException( "Cannot specify more than two node labels" + " in a single node label expression"); } }
/** * ContainerRequests with locality relaxation cannot be made at the same * priority as ContainerRequests without locality relaxation. */ private void checkLocalityRelaxationConflict(Priority priority, Collection<String> locations, boolean relaxLocality) { Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { return; } // Locality relaxation will be set to relaxLocality for all implicitly // requested racks. Make sure that existing rack requests match this. for (String location : locations) { TreeMap<Resource, ResourceRequestInfo> reqs = remoteRequests.get(location); if (reqs != null && !reqs.isEmpty()) { boolean existingRelaxLocality = reqs.values().iterator().next().remoteRequest.getRelaxLocality(); if (relaxLocality != existingRelaxLocality) { throw new InvalidContainerRequestException("Cannot submit a " + "ContainerRequest asking for location " + location + " with locality relaxation " + relaxLocality + " when it has " + "already been requested with locality relaxation " + existingRelaxLocality); } } } }
/** * ContainerRequests with locality relaxation cannot be made at the same * priority as ContainerRequests without locality relaxation. */ private void checkLocalityRelaxationConflict(Priority priority, Collection<String> locations, boolean relaxLocality) { Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { return; } // Locality relaxation will be set to relaxLocality for all implicitly // requested racks. Make sure that existing rack requests match this. for (String location : locations) { TreeMap<Resource, ResourceRequestInfo> reqs = remoteRequests.get(location); if (reqs != null && !reqs.isEmpty()) { boolean existingRelaxLocality = reqs.values().iterator().next().remoteRequest.getRelaxLocality(); if (relaxLocality != existingRelaxLocality) { throw new InvalidContainerRequestException("Cannot submit a " + "ContainerRequest asking for location " + location + " with locality relaxation " + relaxLocality + " when it has " + "already been requested with locality relaxation " + existingRelaxLocality); } } } }
/** * ContainerRequests with locality relaxation cannot be made at the same * priority as ContainerRequests without locality relaxation. */ private void checkLocalityRelaxationConflict(Priority priority, Collection<String> locations, boolean relaxLocality) { Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { return; } // Locality relaxation will be set to relaxLocality for all implicitly // requested racks. Make sure that existing rack requests match this. for (String location : locations) { TreeMap<Resource, ResourceRequestInfo> reqs = remoteRequests.get(location); if (reqs != null && !reqs.isEmpty()) { boolean existingRelaxLocality = reqs.values().iterator().next().remoteRequest.getRelaxLocality(); if (relaxLocality != existingRelaxLocality) { throw new InvalidContainerRequestException("Cannot submit a " + "ContainerRequest asking for location " + location + " with locality relaxation " + relaxLocality + " when it has " + "already been requested with locality relaxation " + existingRelaxLocality); } } } }
/** * Valid if a node label expression specified on container request is valid or * not * * @param containerRequest */ private void checkNodeLabelExpression(T containerRequest) { String exp = containerRequest.getNodeLabelExpression(); if (null == exp || exp.isEmpty()) { return; } // Don't support specifying >= 2 node labels in a node label expression now if (exp.contains("&&") || exp.contains("||")) { throw new InvalidContainerRequestException( "Cannot specify more than two node labels" + " in a single node label expression"); } // Don't allow specify node label against ANY request if ((containerRequest.getRacks() != null && (!containerRequest.getRacks().isEmpty())) || (containerRequest.getNodes() != null && (!containerRequest.getNodes().isEmpty()))) { throw new InvalidContainerRequestException( "Cannot specify node label with rack and node"); } }
/** * Inner Validation logic for container request * @param containerRequest request * @param priority raw priority of role * @param requestDetails details for error messages */ @VisibleForTesting public static void validateContainerRequest(AMRMClient.ContainerRequest containerRequest, int priority, String requestDetails) { String exp = containerRequest.getNodeLabelExpression(); boolean hasRacks = containerRequest.getRacks() != null && (!containerRequest.getRacks().isEmpty()); boolean hasNodes = containerRequest.getNodes() != null && (!containerRequest.getNodes().isEmpty()); boolean hasLabel = SliderUtils.isSet(exp); // Don't support specifying >= 2 node labels in a node label expression now if (hasLabel && (exp.contains("&&") || exp.contains("||"))) { throw new InvalidContainerRequestException( "Cannot specify more than two node labels" + " in a single node label expression: " + requestDetails); } // Don't allow specify node label against ANY request listing hosts or racks if (hasLabel && ( hasRacks || hasNodes)) { throw new InvalidContainerRequestException( "Cannot specify node label with rack or node: " + requestDetails); } }
/** * Inner Validation logic for container request * @param containerRequest request * @param priority raw priority of role * @param requestDetails details for error messages */ @VisibleForTesting public static void validateContainerRequest(AMRMClient.ContainerRequest containerRequest, int priority, String requestDetails) { String exp = containerRequest.getNodeLabelExpression(); boolean hasRacks = containerRequest.getRacks() != null && (!containerRequest.getRacks().isEmpty()); boolean hasNodes = containerRequest.getNodes() != null && (!containerRequest.getNodes().isEmpty()); boolean hasLabel = SliderUtils.isSet(exp); // Don't support specifying >= 2 node labels in a node label expression now if (hasLabel && (exp.contains("&&") || exp.contains("||"))) { throw new InvalidContainerRequestException( "Cannot specify more than two node labels" + " in a single node label expression: " + requestDetails); } // Don't allow specify node label against ANY request listing hosts or racks if (hasLabel && ( hasRacks || hasNodes)) { throw new InvalidContainerRequestException( "Cannot specify node label with rack or node: " + requestDetails); } }
private Resource checkAndGetResourceProfile(String profile, Resource overrideResource) { Resource returnResource = overrideResource; // if application requested a non-empty/null profile, and the if (profile != null && !profile.isEmpty()) { if (resourceProfilesMap == null || (!resourceProfilesMap.containsKey( profile))) { throw new InvalidContainerRequestException( "Invalid profile name specified=" + profile + ( resourceProfilesMap == null ? "" : (", valid profile names are " + resourceProfilesMap .keySet()))); } returnResource = Resources.clone(resourceProfilesMap.get(profile)); for (ResourceInformation info : overrideResource .getAllResourcesListCopy()) { if (info.getValue() > 0) { returnResource.setResourceInformation(info.getName(), info); } } } return returnResource; }
/** * ContainerRequests with locality relaxation cannot be made at the same * priority as ContainerRequests without locality relaxation. */ private void checkLocalityRelaxationConflict(Long allocationReqId, Priority priority, Collection<String> locations, boolean relaxLocality) { // Locality relaxation will be set to relaxLocality for all implicitly // requested racks. Make sure that existing rack requests match this. RemoteRequestsTable<T> remoteRequestsTable = getTable(allocationReqId); if (remoteRequestsTable != null) { @SuppressWarnings("unchecked") List<ResourceRequestInfo> allCapabilityMaps = remoteRequestsTable.getAllResourceRequestInfos(priority, locations); for (ResourceRequestInfo reqs : allCapabilityMaps) { ResourceRequest remoteRequest = reqs.remoteRequest; boolean existingRelaxLocality = remoteRequest.getRelaxLocality(); if (relaxLocality != existingRelaxLocality) { throw new InvalidContainerRequestException("Cannot submit a " + "ContainerRequest asking for location " + remoteRequest.getResourceName() + " with locality relaxation " + relaxLocality + " when it has already been requested" + "with locality relaxation " + existingRelaxLocality); } } } }