public static String requestToString(AMRMClient.ContainerRequest request) { Preconditions.checkArgument(request != null, "Null request"); StringBuilder buffer = new StringBuilder(request.toString()); buffer.append("; "); buffer.append("relaxLocality=").append(request.getRelaxLocality()).append("; "); String labels = request.getNodeLabelExpression(); if (labels != null) { buffer.append("nodeLabels=").append(labels).append("; "); } List<String> nodes = request.getNodes(); if (nodes != null) { buffer.append("Nodes = [ "); int size = nodes.size(); for (int i = 0; i < Math.min(NODE_LIST_LIMIT, size); i++) { buffer.append(nodes.get(i)).append(' '); } if (size > NODE_LIST_LIMIT) { buffer.append(String.format("...(total %d entries)", size)); } buffer.append("]; "); } List<String> racks = request.getRacks(); if (racks != null) { buffer.append("racks = [") .append(join(racks, ", ", false)) .append("]; "); } return buffer.toString(); }
public static String requestToString(AMRMClient.ContainerRequest request) { Preconditions.checkArgument(request != null, "Null request"); StringBuilder buffer = new StringBuilder(request.toString()); buffer.append("; "); buffer.append("relaxLocality=").append(request.getRelaxLocality()).append("; "); String labels = request.getNodeLabelExpression(); if (labels != null) { buffer.append("nodeLabels=").append(labels).append("; "); } List<String> nodes = request.getNodes(); if (nodes != null) { buffer.append("Nodes = [ "); int size = nodes.size(); for (int i = 0; i < Math.min(NODE_LIST_LIMIT, size); i++) { buffer.append(nodes.get(i)).append(' '); } if (size > NODE_LIST_LIMIT) { buffer.append(String.format("...(total %d entries)", size)); } buffer.append("]; "); } List<String> racks = request.getRacks(); if (racks != null) { buffer.append("racks = [") .append(join(racks, ", ", false)) .append("]; "); } return buffer.toString(); }
/** * 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"); } }
addResourceRequest(req.getPriority(), node, req.getExecutionTypeRequest(), resource, req, true, req.getNodeLabelExpression()); resource, req, true, req.getNodeLabelExpression()); addResourceRequest(req.getPriority(), rack, req.getExecutionTypeRequest(), resource, req, req.getRelaxLocality(), req.getNodeLabelExpression()); req.getRelaxLocality(), req.getNodeLabelExpression());
true, req.getNodeLabelExpression()); true, req.getNodeLabelExpression()); req.getRelaxLocality(), req.getNodeLabelExpression()); req.getCapability(), req, req.getRelaxLocality(), req.getNodeLabelExpression());
true, req.getNodeLabelExpression()); true, req.getNodeLabelExpression()); req.getRelaxLocality(), req.getNodeLabelExpression()); req.getCapability(), req, req.getRelaxLocality(), req.getNodeLabelExpression());
true, req.getNodeLabelExpression()); true, req.getNodeLabelExpression()); req.getRelaxLocality(), req.getNodeLabelExpression()); req.getCapability(), req, req.getRelaxLocality(), req.getNodeLabelExpression());
/** * 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); } }
/** * Add a container request if the request is non-null * @param operations operations to add the entry to * @param containerAsk what to ask for * @return true if a request was added */ private boolean addContainerRequest(List<AbstractRMOperation> operations, AMRMClient.ContainerRequest containerAsk) { if (containerAsk != null) { log.info("Container ask is {} and label = {}", containerAsk, containerAsk.getNodeLabelExpression()); int askMemory = containerAsk.getCapability().getMemory(); if (askMemory > this.containerMaxMemory) { log.warn("Memory requested: {} > max of {}", askMemory, containerMaxMemory); } operations.add(new ContainerRequestOperation(containerAsk)); return true; } else { return false; } }
/** * Add a container request if the request is non-null * @param operations operations to add the entry to * @param containerAsk what to ask for * @return true if a request was added */ private boolean addContainerRequest(List<AbstractRMOperation> operations, AMRMClient.ContainerRequest containerAsk) { if (containerAsk != null) { log.info("Container ask is {} and label = {}", containerAsk, containerAsk.getNodeLabelExpression()); int askMemory = containerAsk.getCapability().getMemory(); if (askMemory > this.containerMaxMemory) { log.warn("Memory requested: {} > max of {}", askMemory, containerMaxMemory); } operations.add(new ContainerRequestOperation(containerAsk)); return true; } else { return false; } }
/** * 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); } }
/** * 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"); } }