-
Notifications
You must be signed in to change notification settings - Fork 9.2k
YARN-11003. Make RMNode aware of all (OContainer inclusive) allocated resources #3646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9e60671
b6ae804
2ee6bf8
7457e09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ | |
| import org.apache.hadoop.yarn.api.records.ContainerId; | ||
| import org.apache.hadoop.yarn.api.records.ContainerState; | ||
| import org.apache.hadoop.yarn.api.records.ContainerStatus; | ||
| import org.apache.hadoop.yarn.api.records.ExecutionType; | ||
| import org.apache.hadoop.yarn.api.records.NodeId; | ||
| import org.apache.hadoop.yarn.api.records.NodeState; | ||
| import org.apache.hadoop.yarn.api.records.Resource; | ||
|
|
@@ -79,6 +80,7 @@ | |
| import org.apache.hadoop.yarn.server.resourcemanager.security.DelegationTokenRenewer; | ||
| import org.apache.hadoop.yarn.server.utils.BuilderUtils; | ||
| import org.apache.hadoop.yarn.util.Records; | ||
| import org.apache.hadoop.yarn.util.resource.Resources; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
|
|
@@ -358,6 +360,94 @@ public void testContainerUpdate() throws InterruptedException{ | |
| .getContainerId()); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that allocated container resources are counted correctly in | ||
| * {@link org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode} | ||
| * upon a node update. Resources should be counted for both GUARANTEED | ||
| * and OPPORTUNISTIC containers. | ||
| */ | ||
| @Test (timeout = 5000) | ||
| public void testAllocatedContainerUpdate() { | ||
| NodeStatus mockNodeStatus = createMockNodeStatus(); | ||
| //Start the node | ||
| node.handle(new RMNodeStartedEvent(null, null, null, mockNodeStatus)); | ||
goiri marked this conversation as resolved.
Show resolved
Hide resolved
bibinchundatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| NodeId nodeId = BuilderUtils.newNodeId("localhost:1", 1); | ||
|
|
||
| ApplicationId app0 = BuilderUtils.newApplicationId(0, 0); | ||
| ContainerId newContainerId = BuilderUtils.newContainerId( | ||
| BuilderUtils.newApplicationAttemptId(app0, 0), 0); | ||
| ContainerId runningContainerId = BuilderUtils.newContainerId( | ||
| BuilderUtils.newApplicationAttemptId(app0, 0), 1); | ||
| ContainerId newOppContainerId = BuilderUtils.newContainerId( | ||
| BuilderUtils.newApplicationAttemptId(app0, 0), 2); | ||
| ContainerId runningOppContainerId = BuilderUtils.newContainerId( | ||
| BuilderUtils.newApplicationAttemptId(app0, 0), 3); | ||
|
|
||
| rmContext.getRMApps().put(app0, Mockito.mock(RMApp.class)); | ||
|
|
||
| RMNodeStatusEvent statusEventFromNode1 = getMockRMNodeStatusEvent(null); | ||
| ContainerStatus newContainerStatusFromNode = mock(ContainerStatus.class); | ||
|
||
| ContainerStatus runningContainerStatusFromNode = | ||
| mock(ContainerStatus.class); | ||
|
|
||
| final Resource newContainerCapability = | ||
| Resource.newInstance(100, 1); | ||
goiri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| final Resource runningContainerCapability = | ||
| Resource.newInstance(200, 2); | ||
| doReturn(newContainerId).when(newContainerStatusFromNode) | ||
| .getContainerId(); | ||
| doReturn(ContainerState.NEW).when(newContainerStatusFromNode) | ||
| .getState(); | ||
| doReturn(newContainerCapability).when(newContainerStatusFromNode) | ||
| .getCapability(); | ||
| doReturn(runningContainerId).when(runningContainerStatusFromNode) | ||
| .getContainerId(); | ||
| doReturn(ContainerState.RUNNING).when(runningContainerStatusFromNode) | ||
| .getState(); | ||
| doReturn(runningContainerCapability).when(runningContainerStatusFromNode) | ||
| .getCapability(); | ||
| doReturn(Arrays.asList( | ||
| newContainerStatusFromNode, runningContainerStatusFromNode)) | ||
| .when(statusEventFromNode1).getContainers(); | ||
| node.handle(statusEventFromNode1); | ||
| Assert.assertTrue(Resources.equals( | ||
|
||
| node.getAllocatedContainerResource(), | ||
| Resource.newInstance(300, 3))); | ||
|
|
||
| RMNodeStatusEvent statusEventFromNode2 = getMockRMNodeStatusEvent(null); | ||
| ContainerStatus newOppContainerStatusFromNode = mock(ContainerStatus.class); | ||
| ContainerStatus runningOppContainerStatusFromNode = | ||
| mock(ContainerStatus.class); | ||
| doReturn(newOppContainerId).when(newOppContainerStatusFromNode) | ||
| .getContainerId(); | ||
| doReturn(ContainerState.NEW).when(newOppContainerStatusFromNode) | ||
| .getState(); | ||
| doReturn(newContainerCapability).when(newOppContainerStatusFromNode) | ||
| .getCapability(); | ||
| doReturn(ExecutionType.OPPORTUNISTIC) | ||
| .when(newOppContainerStatusFromNode) | ||
| .getExecutionType(); | ||
| doReturn(runningOppContainerId).when(runningOppContainerStatusFromNode) | ||
| .getContainerId(); | ||
| doReturn(ContainerState.RUNNING).when(runningOppContainerStatusFromNode) | ||
| .getState(); | ||
| doReturn(runningContainerCapability).when(runningOppContainerStatusFromNode) | ||
| .getCapability(); | ||
| doReturn(ExecutionType.OPPORTUNISTIC) | ||
| .when(runningOppContainerStatusFromNode) | ||
| .getExecutionType(); | ||
| doReturn(Arrays.asList( | ||
| newContainerStatusFromNode, runningContainerStatusFromNode, | ||
| newOppContainerStatusFromNode, runningOppContainerStatusFromNode)) | ||
| .when(statusEventFromNode2).getContainers(); | ||
|
|
||
| node.handle(statusEventFromNode2); | ||
| Assert.assertTrue(Resources.equals( | ||
|
||
| node.getAllocatedContainerResource(), | ||
| Resource.newInstance(600, 6))); | ||
| } | ||
|
|
||
| @Test (timeout = 5000) | ||
| public void testStatusChange(){ | ||
| NodeStatus mockNodeStatus = createMockNodeStatus(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start with upper case in comments.. This will include the sum of O+G containers queued + running + paused on the node.. Comment cane be more explanatory..