@Override public DistributedSchedulingAllocateResponse allocateForDistributedScheduling( DistributedSchedulingAllocateRequest request) throws YarnException, IOException { List<Container> distAllocContainers = request.getAllocatedContainers(); handleNewContainers(distAllocContainers, true); AllocateResponse response = allocate(request.getAllocateRequest()); DistributedSchedulingAllocateResponse dsResp = recordFactory .newRecordInstance(DistributedSchedulingAllocateResponse.class); dsResp.setAllocateResponse(response); dsResp.setNodesForScheduling(getLeastLoadedNodes()); return dsResp; }
/** * Route allocate call to the allocateForDistributedScheduling method and * return response to the caller after stripping away Distributed Scheduling * information. * * @param request * allocation request * @return Allocate Response * @throws YarnException YarnException * @throws IOException IOException */ @Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { DistributedSchedulingAllocateRequest distRequest = RECORD_FACTORY .newRecordInstance(DistributedSchedulingAllocateRequest.class); distRequest.setAllocateRequest(request); return allocateForDistributedScheduling(distRequest).getAllocateResponse(); }
setNodeList(dsResp.getNodesForScheduling()); List<NMToken> nmTokens = dsResp.getAllocateResponse().getNMTokens(); for (NMToken nmToken : nmTokens) { nodeTokens.put(nmToken.getNodeId(), nmToken); dsResp.getAllocateResponse(), nmTokens, allocatedContainers);
@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; } };
distAllReq.getProto())); Assert.assertEquals( "h1", dsAllocResp.getNodesForScheduling().get(0).getNodeId().getHost()); Assert.assertEquals( "l1", dsAllocResp.getNodesForScheduling().get(1).getNodePartition());
@Override public DistributedSchedulingAllocateResponse allocateForDistributedScheduling( DistributedSchedulingAllocateRequest request) throws YarnException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Forwarding allocateForDistributedScheduling request" + "to the real YARN RM"); } if (getApplicationContext().getNMCotext() .isDistributedSchedulingEnabled()) { DistributedSchedulingAllocateResponse allocateResponse = ((DistributedSchedulingAMProtocol)rmClient) .allocateForDistributedScheduling(request); if (allocateResponse.getAllocateResponse().getAMRMToken() != null) { YarnServerSecurityUtils.updateAMRMToken( allocateResponse.getAllocateResponse().getAMRMToken(), this.user, getConf()); } return allocateResponse; } else { throw new YarnException("Distributed Scheduling is not enabled."); } }