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 int compare(ResourceRequest r1, ResourceRequest r2) { // Compare priority, host and capability int ret = r1.getPriority().compareTo(r2.getPriority()); if (ret == 0) { ret = Long.compare( r1.getAllocationRequestId(), r2.getAllocationRequestId()); } if (ret == 0) { String h1 = r1.getResourceName(); String h2 = r2.getResourceName(); ret = h1.compareTo(h2); } if (ret == 0) { ret = r1.getExecutionTypeRequest() .compareTo(r2.getExecutionTypeRequest()); } if (ret == 0) { ret = r1.getCapability().compareTo(r2.getCapability()); } return ret; } }
this.getResourceName().compareTo(other.getResourceName()); if (hostNameComparison == 0) { int execTypeReqComparison = this.getExecutionTypeRequest() .compareTo(other.getExecutionTypeRequest()); if (execTypeReqComparison == 0) { int capabilityComparison =
} else if (!priority.equals(other.getPriority())) return false; ExecutionTypeRequest execTypeRequest = getExecutionTypeRequest(); if (execTypeRequest == null) { if (other.getExecutionTypeRequest() != null) { return false; } else if (!execTypeRequest.equals(other.getExecutionTypeRequest())) { return false;
@Override public DistributedSchedulingAllocateResponse allocateForDistributedScheduling( DistributedSchedulingAllocateRequest request) throws YarnException, IOException { List<ResourceRequest> askList = request.getAllocateRequest().getAskList(); List<Container> allocatedContainers = request.getAllocatedContainers(); Assert.assertEquals(1, allocatedContainers.size()); Assert.assertEquals(ExecutionType.OPPORTUNISTIC, allocatedContainers.get(0).getExecutionType()); Assert.assertEquals(1, askList.size()); Assert.assertTrue(askList.get(0) .getExecutionTypeRequest().getEnforceExecutionType()); DistributedSchedulingAllocateResponse resp = factory .newRecordInstance(DistributedSchedulingAllocateResponse.class); RemoteNode remoteNode1 = RemoteNode.newInstance( NodeId.newInstance("h1", 1234), "http://h1:4321"); RemoteNode remoteNode2 = RemoteNode.newInstance( NodeId.newInstance("h2", 1234), "http://h2:4321"); remoteNode2.setNodePartition("l1"); resp.setNodesForScheduling( Arrays.asList(remoteNode1, remoteNode2)); return resp; } };
.getElementsByTagName("executionTypeRequest").item(0); assertEquals("executionType does not match", resourceRequest.getExecutionTypeRequest().getExecutionType().name(), getXmlString(executionTypeRequest, "executionType")); assertEquals("enforceExecutionType does not match", resourceRequest.getExecutionTypeRequest().getEnforceExecutionType(), getXmlBoolean(executionTypeRequest, "enforceExecutionType"));
/** * 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(); }
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.getJSONObject("executionTypeRequest"); assertEquals("executionType does not match", resourceRequest.getExecutionTypeRequest().getExecutionType().name(), executionTypeRequest.getString("executionType")); assertEquals("enforceExecutionType does not match", resourceRequest.getExecutionTypeRequest().getEnforceExecutionType(), executionTypeRequest.getBoolean("enforceExecutionType"));