@Override public boolean canDelayTo(String resourceName) { try { readLock.lock(); ResourceRequest request = getResourceRequest(resourceName); return request == null || request.getRelaxLocality(); } finally { readLock.unlock(); } }
/** * 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); } } } }
private List<ResourceRequest> cloneAsks() { List<ResourceRequest> askList = new ArrayList<ResourceRequest>(ask.size()); for(ResourceRequest r : ask) { // create a copy of ResourceRequest as we might change it while the // RPC layer is using it to send info across ResourceRequest rr = ResourceRequest.newInstance(r.getPriority(), r.getResourceName(), r.getCapability(), r.getNumContainers(), r.getRelaxLocality(), r.getNodeLabelExpression()); askList.add(rr); } return askList; }
public ResourceRequest cloneResourceRequest(ResourceRequest request) { ResourceRequest newRequest = ResourceRequest.newInstance( request.getPriority(), request.getResourceName(), request.getCapability(), 1, request.getRelaxLocality()); return newRequest; } }
public ResourceRequest cloneResourceRequest(ResourceRequest request) { ResourceRequest newRequest = ResourceRequest.newInstance( request.getPriority(), request.getResourceName(), request.getCapability(), 1, request.getRelaxLocality()); return newRequest; } }
if (amReq.getRelaxLocality() && !amReq.getResourceName().equals(ResourceRequest.ANY)) { nodesForReqs.addAll(
/** * 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); } } } }
/** * Whether this app has containers requests that could be satisfied on the * given node, if the node had full space. */ public boolean hasContainerForNode(Priority prio, FSSchedulerNode node) { ResourceRequest anyRequest = getResourceRequest(prio, ResourceRequest.ANY); ResourceRequest rackRequest = getResourceRequest(prio, node.getRackName()); ResourceRequest nodeRequest = getResourceRequest(prio, node.getNodeName()); return // There must be outstanding requests at the given priority: anyRequest != null && anyRequest.getNumContainers() > 0 && // If locality relaxation is turned off at *-level, there must be a // non-zero request for the node's rack: (anyRequest.getRelaxLocality() || (rackRequest != null && rackRequest.getNumContainers() > 0)) && // If locality relaxation is turned off at rack-level, there must be a // non-zero request at the node: (rackRequest == null || rackRequest.getRelaxLocality() || (nodeRequest != null && nodeRequest.getNumContainers() > 0)) && // The requested container must be able to fit on the node: Resources.lessThanOrEqual(RESOURCE_CALCULATOR, null, anyRequest.getCapability(), node.getRMNode().getTotalCapability()); }
/** * Whether this app has containers requests that could be satisfied on the * given node, if the node had full space. */ public boolean hasContainerForNode(Priority prio, FSSchedulerNode node) { ResourceRequest anyRequest = getResourceRequest(prio, ResourceRequest.ANY); ResourceRequest rackRequest = getResourceRequest(prio, node.getRackName()); ResourceRequest nodeRequest = getResourceRequest(prio, node.getNodeName()); return // There must be outstanding requests at the given priority: anyRequest != null && anyRequest.getNumContainers() > 0 && // If locality relaxation is turned off at *-level, there must be a // non-zero request for the node's rack: (anyRequest.getRelaxLocality() || (rackRequest != null && rackRequest.getNumContainers() > 0)) && // If locality relaxation is turned off at rack-level, there must be a // non-zero request at the node: (rackRequest == null || rackRequest.getRelaxLocality() || (nodeRequest != null && nodeRequest.getNumContainers() > 0)) && // The requested container must be able to fit on the node: Resources.lessThanOrEqual(RESOURCE_CALCULATOR, null, anyRequest.getCapability(), node.getRMNode().getTotalCapability()); }
ResourceRequest reqCopy = ResourceRequest.newInstance(req .getPriority(), req.getResourceName(), req.getCapability(), req .getNumContainers(), req.getRelaxLocality()); askCopy.add(reqCopy);
public ResourceRequestInfo(ResourceRequest request) { priority = request.getPriority().getPriority(); allocationRequestId = request.getAllocationRequestId(); resourceName = request.getResourceName(); capability = new ResourceInfo(request.getCapability()); numContainers = request.getNumContainers(); relaxLocality = request.getRelaxLocality(); nodeLabelExpression = request.getNodeLabelExpression(); if (request.getExecutionTypeRequest() != null) { executionTypeRequest = new ExecutionTypeRequestInfo(request.getExecutionTypeRequest()); } }
@Override public synchronized Allocation allocate( ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask, List<SchedulingRequest> schedulingRequests, List<ContainerId> release, List<String> blacklistAdditions, List<String> blacklistRemovals, ContainerUpdates updateRequests) { List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>(); for (ResourceRequest req : ask) { ResourceRequest reqCopy = ResourceRequest.newInstance(req .getPriority(), req.getResourceName(), req.getCapability(), req .getNumContainers(), req.getRelaxLocality()); askCopy.add(reqCopy); } SecurityUtil.setTokenServiceUseIp(false); lastAsk = ask; lastRelease = release; lastBlacklistAdditions = blacklistAdditions; lastBlacklistRemovals = blacklistRemovals; Allocation allocation = super.allocate( applicationAttemptId, askCopy, schedulingRequests, release, blacklistAdditions, blacklistRemovals, updateRequests); if (forceResourceLimit != null) { // Test wants to force the non-default resource limit allocation.setResourceLimit(forceResourceLimit); } return allocation; }
.td(String.valueOf(request.getCapability())) .td(String.valueOf(request.getNumContainers())) .td(String.valueOf(request.getRelaxLocality())) .td(request.getNodeLabelExpression() == null ? "N/A" : request .getNodeLabelExpression())._();
.td(String.valueOf(request.getCapability())) .td(String.valueOf(request.getNumContainers())) .td(String.valueOf(request.getRelaxLocality())) .td(request.getNodeLabelExpression() == null ? "N/A" : request .getNodeLabelExpression())._();
/** * Clone a ResourceRequest object (shallow copy). Please keep it loaded with * all (new) fields * * @param rr the object to copy from * @return the copied object */ @Public @Evolving public static ResourceRequest clone(ResourceRequest rr) { // Please keep it loaded with all (new) fields return ResourceRequest.newBuilder().priority(rr.getPriority()) .resourceName(rr.getResourceName()).capability(rr.getCapability()) .numContainers(rr.getNumContainers()) .relaxLocality(rr.getRelaxLocality()) .nodeLabelExpression(rr.getNodeLabelExpression()) .executionTypeRequest(rr.getExecutionTypeRequest()) .allocationRequestId(rr.getAllocationRequestId()).build(); }
getXmlInt(requestInfo, "numContainers")); assertEquals("relaxLocality doesn't match", resourceRequest.getRelaxLocality(), getXmlBoolean(requestInfo, "relaxLocality")); assertEquals("priority does not match",
public void verifyResourceRequestsGeneric(ResourceRequest request, String nodeLabelExpression, int numContainers, boolean relaxLocality, int priority, String resourceName, long memory, long vCores, String executionType, boolean enforceExecutionType) { assertEquals("nodeLabelExpression doesn't match", request.getNodeLabelExpression(), nodeLabelExpression); assertEquals("numContainers doesn't match", request.getNumContainers(), numContainers); assertEquals("relaxLocality doesn't match", request.getRelaxLocality(), relaxLocality); assertEquals("priority does not match", request.getPriority().getPriority(), priority); assertEquals("resourceName does not match", request.getResourceName(), resourceName); assertEquals("memory does not match", request.getCapability().getMemorySize(), memory); assertEquals("vCores does not match", request.getCapability().getVirtualCores(), vCores); assertEquals("executionType does not match", request.getExecutionTypeRequest().getExecutionType().name(), executionType); assertEquals("enforceExecutionType does not match", request.getExecutionTypeRequest().getEnforceExecutionType(), enforceExecutionType); }
requestInfo.getInt("numContainers")); assertEquals("relaxLocality doesn't match", resourceRequest.getRelaxLocality(), requestInfo.getBoolean("relaxLocality")); assertEquals("priority does not match",