|
@@ -47,6 +47,7 @@ import org.apache.hadoop.yarn.event.InlineDispatcher;
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse;
|
|
import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse;
|
|
import org.apache.hadoop.yarn.server.api.records.NodeHealthStatus;
|
|
import org.apache.hadoop.yarn.server.api.records.NodeHealthStatus;
|
|
import org.apache.hadoop.yarn.server.api.records.NodeStatus;
|
|
import org.apache.hadoop.yarn.server.api.records.NodeStatus;
|
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer
|
|
.AllocationExpirationInfo;
|
|
.AllocationExpirationInfo;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer;
|
|
@@ -73,6 +74,7 @@ import org.junit.After;
|
|
import org.junit.Assert;
|
|
import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
+import org.mockito.Mockito;
|
|
import org.mockito.invocation.InvocationOnMock;
|
|
import org.mockito.invocation.InvocationOnMock;
|
|
import org.mockito.stubbing.Answer;
|
|
import org.mockito.stubbing.Answer;
|
|
|
|
|
|
@@ -290,16 +292,17 @@ public class TestRMNodeTransitions {
|
|
NodeId nodeId = BuilderUtils.newNodeId("localhost:1", 1);
|
|
NodeId nodeId = BuilderUtils.newNodeId("localhost:1", 1);
|
|
RMNodeImpl node2 = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null);
|
|
RMNodeImpl node2 = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null);
|
|
node2.handle(new RMNodeStartedEvent(null, null, null));
|
|
node2.handle(new RMNodeStartedEvent(null, null, null));
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ ApplicationId app0 = BuilderUtils.newApplicationId(0, 0);
|
|
|
|
+ ApplicationId app1 = BuilderUtils.newApplicationId(1, 1);
|
|
ContainerId completedContainerIdFromNode1 = BuilderUtils.newContainerId(
|
|
ContainerId completedContainerIdFromNode1 = BuilderUtils.newContainerId(
|
|
- BuilderUtils.newApplicationAttemptId(
|
|
|
|
- BuilderUtils.newApplicationId(0, 0), 0), 0);
|
|
|
|
|
|
+ BuilderUtils.newApplicationAttemptId(app0, 0), 0);
|
|
ContainerId completedContainerIdFromNode2_1 = BuilderUtils.newContainerId(
|
|
ContainerId completedContainerIdFromNode2_1 = BuilderUtils.newContainerId(
|
|
- BuilderUtils.newApplicationAttemptId(
|
|
|
|
- BuilderUtils.newApplicationId(1, 1), 1), 1);
|
|
|
|
|
|
+ BuilderUtils.newApplicationAttemptId(app1, 1), 1);
|
|
ContainerId completedContainerIdFromNode2_2 = BuilderUtils.newContainerId(
|
|
ContainerId completedContainerIdFromNode2_2 = BuilderUtils.newContainerId(
|
|
- BuilderUtils.newApplicationAttemptId(
|
|
|
|
- BuilderUtils.newApplicationId(1, 1), 1), 2);
|
|
|
|
|
|
+ BuilderUtils.newApplicationAttemptId(app1, 1), 2);
|
|
|
|
+ rmContext.getRMApps().put(app0, Mockito.mock(RMApp.class));
|
|
|
|
+ rmContext.getRMApps().put(app1, Mockito.mock(RMApp.class));
|
|
|
|
|
|
RMNodeStatusEvent statusEventFromNode1 = getMockRMNodeStatusEvent(null);
|
|
RMNodeStatusEvent statusEventFromNode1 = getMockRMNodeStatusEvent(null);
|
|
RMNodeStatusEvent statusEventFromNode2_1 = getMockRMNodeStatusEvent(null);
|
|
RMNodeStatusEvent statusEventFromNode2_1 = getMockRMNodeStatusEvent(null);
|
|
@@ -663,6 +666,7 @@ public class TestRMNodeTransitions {
|
|
NodeId nodeId = node.getNodeID();
|
|
NodeId nodeId = node.getNodeID();
|
|
|
|
|
|
ApplicationId runningAppId = BuilderUtils.newApplicationId(0, 1);
|
|
ApplicationId runningAppId = BuilderUtils.newApplicationId(0, 1);
|
|
|
|
+ rmContext.getRMApps().put(runningAppId, Mockito.mock(RMApp.class));
|
|
// Create a running container
|
|
// Create a running container
|
|
ContainerId runningContainerId = BuilderUtils.newContainerId(
|
|
ContainerId runningContainerId = BuilderUtils.newContainerId(
|
|
BuilderUtils.newApplicationAttemptId(
|
|
BuilderUtils.newApplicationAttemptId(
|
|
@@ -930,16 +934,22 @@ public class TestRMNodeTransitions {
|
|
}
|
|
}
|
|
|
|
|
|
// Test unhealthy report on a decommissioning node will make it
|
|
// Test unhealthy report on a decommissioning node will make it
|
|
- // keep decommissioning.
|
|
|
|
|
|
+ // keep decommissioning as long as there's a running or keep alive app.
|
|
|
|
+ // Otherwise, it will go to decommissioned
|
|
@Test
|
|
@Test
|
|
public void testDecommissioningUnhealthy() {
|
|
public void testDecommissioningUnhealthy() {
|
|
RMNodeImpl node = getDecommissioningNode();
|
|
RMNodeImpl node = getDecommissioningNode();
|
|
NodeHealthStatus status = NodeHealthStatus.newInstance(false, "sick",
|
|
NodeHealthStatus status = NodeHealthStatus.newInstance(false, "sick",
|
|
System.currentTimeMillis());
|
|
System.currentTimeMillis());
|
|
|
|
+ List<ApplicationId> keepAliveApps = new ArrayList<>();
|
|
|
|
+ keepAliveApps.add(BuilderUtils.newApplicationId(1, 1));
|
|
NodeStatus nodeStatus = NodeStatus.newInstance(node.getNodeID(), 0,
|
|
NodeStatus nodeStatus = NodeStatus.newInstance(node.getNodeID(), 0,
|
|
- new ArrayList<ContainerStatus>(), null, status, null, null, null);
|
|
|
|
|
|
+ null, keepAliveApps, status, null, null, null);
|
|
node.handle(new RMNodeStatusEvent(node.getNodeID(), nodeStatus, null));
|
|
node.handle(new RMNodeStatusEvent(node.getNodeID(), nodeStatus, null));
|
|
Assert.assertEquals(NodeState.DECOMMISSIONING, node.getState());
|
|
Assert.assertEquals(NodeState.DECOMMISSIONING, node.getState());
|
|
|
|
+ nodeStatus.setKeepAliveApplications(null);
|
|
|
|
+ node.handle(new RMNodeStatusEvent(node.getNodeID(), nodeStatus, null));
|
|
|
|
+ Assert.assertEquals(NodeState.DECOMMISSIONED, node.getState());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -962,6 +972,7 @@ public class TestRMNodeTransitions {
|
|
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
|
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
|
ApplicationAttemptId appAttemptId =
|
|
ApplicationAttemptId appAttemptId =
|
|
ApplicationAttemptId.newInstance(appId, 1);
|
|
ApplicationAttemptId.newInstance(appId, 1);
|
|
|
|
+ rmContext.getRMApps().put(appId, Mockito.mock(RMApp.class));
|
|
ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1L);
|
|
ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1L);
|
|
ContainerId containerId2 = ContainerId.newContainerId(appAttemptId, 2L);
|
|
ContainerId containerId2 = ContainerId.newContainerId(appAttemptId, 2L);
|
|
AllocationExpirationInfo expirationInfo1 =
|
|
AllocationExpirationInfo expirationInfo1 =
|