|
51 | 51 | import org.apache.hadoop.yarn.event.EventHandler; |
52 | 52 | import org.apache.hadoop.yarn.event.InlineDispatcher; |
53 | 53 | import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; |
| 54 | +import org.apache.hadoop.yarn.server.api.records.NodeAction; |
54 | 55 | import org.apache.hadoop.yarn.server.api.records.NodeHealthStatus; |
55 | 56 | import org.apache.hadoop.yarn.server.api.records.NodeStatus; |
56 | 57 | import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; |
|
76 | 77 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType; |
77 | 78 | import org.apache.hadoop.yarn.server.resourcemanager.security.DelegationTokenRenewer; |
78 | 79 | import org.apache.hadoop.yarn.server.utils.BuilderUtils; |
| 80 | +import org.apache.hadoop.yarn.server.utils.YarnServerBuilderUtils; |
79 | 81 | import org.apache.hadoop.yarn.util.Records; |
80 | 82 | import org.junit.After; |
81 | 83 | import org.junit.Assert; |
@@ -1286,4 +1288,27 @@ public void testCalculateHeartBeatInterval() { |
1286 | 1288 | calcIntervalTest(rmNode, nodeUtil, hbDefault, hbMin, hbMax, |
1287 | 1289 | speedup, slowdown, vcoreUnit * 1.0F, hbDefault); // 100% |
1288 | 1290 | } |
| 1291 | + |
| 1292 | + @Test |
| 1293 | + public void testFinishedContainersPulledByAmOnDecommissioningNode() { |
| 1294 | + RMNodeImpl rMNodeImpl = getRunningNode(); |
| 1295 | + rMNodeImpl.handle( |
| 1296 | + new RMNodeEvent(rMNodeImpl.getNodeID(), RMNodeEventType.GRACEFUL_DECOMMISSION)); |
| 1297 | + Assert.assertEquals(NodeState.DECOMMISSIONING, rMNodeImpl.getState()); |
| 1298 | + |
| 1299 | + ContainerId containerId = BuilderUtils.newContainerId( |
| 1300 | + BuilderUtils.newApplicationAttemptId(BuilderUtils.newApplicationId(0, 0), 0), 0); |
| 1301 | + List<ContainerId> containerIds = Arrays.asList(containerId); |
| 1302 | + |
| 1303 | + rMNodeImpl.handle( |
| 1304 | + new RMNodeFinishedContainersPulledByAMEvent(rMNodeImpl.getNodeID(), containerIds)); |
| 1305 | + Assert.assertEquals(NodeState.DECOMMISSIONING, rMNodeImpl.getState()); |
| 1306 | + |
| 1307 | + // Verify expected containersToBeRemovedFromNM from NodeHeartbeatResponse. |
| 1308 | + NodeHeartbeatResponse response = |
| 1309 | + YarnServerBuilderUtils.newNodeHeartbeatResponse(1, NodeAction.NORMAL, null, null, null, |
| 1310 | + null, 1000); |
| 1311 | + rMNodeImpl.setAndUpdateNodeHeartbeatResponse(response); |
| 1312 | + Assert.assertEquals(1, response.getContainersToBeRemovedFromNM().size()); |
| 1313 | + } |
1289 | 1314 | } |
0 commit comments