@Override public ExecutionType getExecutionType() { return container.getExecutionType(); }
/** * Update the resources of the node when releasing a container. * @param container Container to release. */ protected synchronized void updateResourceForReleasedContainer( Container container) { if (container.getExecutionType() == ExecutionType.GUARANTEED) { addUnallocatedResource(container.getResource()); --numContainers; } }
@Override public void onContainerStatusReceived(ContainerId containerId, ContainerStatus containerStatus) { if (LOG.isDebugEnabled()) { LOG.debug("Container Status: id=" + containerId + ", status=" + containerStatus); } // If promote_opportunistic_after_start is set, automatically promote // opportunistic containers to guaranteed. if (autoPromoteContainers) { if (containerStatus.getState() == ContainerState.RUNNING) { Container container = containers.get(containerId); if (container.getExecutionType() == ExecutionType.OPPORTUNISTIC) { // Promote container LOG.info("Promoting container {} to {}", container.getId(), container.getExecutionType()); UpdateContainerRequest updateRequest = UpdateContainerRequest .newInstance(container.getVersion(), container.getId(), ContainerUpdateType.PROMOTE_EXECUTION_TYPE, null, ExecutionType.GUARANTEED); amRMClient.requestContainerUpdate(container, updateRequest); } } } }
private RMContainer createContainer( Resource request, ApplicationAttemptId appAttemptId) { RMContainer container = mock(RMContainer.class); Container containerInner = mock(Container.class); ContainerId id = mock(ContainerId.class); when(id.getContainerId()).thenReturn((long)containers.size()); when(containerInner.getResource()). thenReturn(Resources.clone(request)); when(containerInner.getId()).thenReturn(id); when(containerInner.getExecutionType()). thenReturn(ExecutionType.GUARANTEED); when(container.getApplicationAttemptId()).thenReturn(appAttemptId); when(container.getContainerId()).thenReturn(id); when(container.getContainer()).thenReturn(containerInner); when(container.getExecutionType()).thenReturn(ExecutionType.GUARANTEED); when(container.getAllocatedResource()). thenReturn(Resources.clone(request)); when(container.compareTo(any())).thenAnswer(new Answer<Integer>() { public Integer answer(InvocationOnMock invocation) { return Long.compare( ((RMContainer)invocation.getMock()).getContainerId() .getContainerId(), ((RMContainer)invocation.getArguments()[0]).getContainerId() .getContainerId()); } }); containers.add(container); return container; }
validateContainerExecTypeChangeRequest( updateContainerRequest.getContainerUpdateType(), container.getId(), container.getExecutionType(), updateContainerRequest.getExecutionType()); } else if (updateContainerRequest.getExecutionType() == null &&
@Override public void onContainersUpdated( List<UpdatedContainer> containers) { for (UpdatedContainer container : containers) { LOG.info("Container {} updated, updateType={}, resource={}, " + "execType={}", container.getContainer().getId(), container.getUpdateType().toString(), container.getContainer().getResource().toString(), container.getContainer().getExecutionType()); // TODO Remove this line with finalized updateContainer API. // Currently nm client needs to notify the NM to update container // execution type via NMClient#updateContainerResource() or // NMClientAsync#updateContainerResourceAsync() when // auto-update.containers is disabled, but this API is // under evolving and will need to be replaced by a proper new API. nmClientAsync.updateContainerResourceAsync(container.getContainer()); } }
@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; } };
updatedResource, existingRMContainer.getContainer().getPriority(), null, tempContainer.getExecutionType()); newContainer.setAllocationRequestId( existingRMContainer.getContainer().getAllocationRequestId()); existingRMContainer.getContainer().getExecutionType());
Assert.assertEquals(container.getId(), uc.getContainer().getId()); Assert.assertEquals(ExecutionType.GUARANTEED, uc.getContainer().getExecutionType()); Assert.assertEquals(container.getId(), containersFromNM.getId()); Assert.assertEquals(ExecutionType.GUARANTEED, containersFromNM.getExecutionType()); uc = allocateResponse.getUpdatedContainers().get(0); Assert.assertEquals(ExecutionType.OPPORTUNISTIC, uc.getContainer().getExecutionType()); response.getContainersToUpdate().get(0).getExecutionType());
container.getPriority(), rmContainer.getCreationTime(), this.logAggregationContext, rmContainer.getNodeLabelExpression(), containerType, container.getExecutionType(), container.getAllocationRequestId(), rmContainer.getAllocationTags()));
Container uc = allocateResponse.getUpdatedContainers().get(0).getContainer(); Assert.assertEquals(ExecutionType.GUARANTEED, uc.getExecutionType()); Assert.assertEquals(uc.getId(), container.getId()); Assert.assertEquals(uc.getVersion(), container.getVersion() + 1); Assert.assertEquals(ExecutionType.OPPORTUNISTIC, uc.getExecutionType()); Assert.assertEquals(uc.getId(), container.getId()); Assert.assertEquals(uc.getVersion(), container.getVersion() + 2);
Container uc = allocateResponse.getUpdatedContainers().get(0).getContainer(); Assert.assertEquals(ExecutionType.GUARANTEED, uc.getExecutionType()); Assert.assertEquals(uc.getId(), container.getId()); Assert.assertEquals(uc.getVersion(), container.getVersion() + 1);
Assert.assertEquals(1, allocatedContainers.size()); Assert.assertEquals(ExecutionType.OPPORTUNISTIC, allocatedContainers.get(0).getExecutionType()); Assert.assertEquals(12345, allocResp.getNumClusterNodes());