diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 887211a36a..5dc127216b 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -91,6 +91,9 @@ Release 2.9.0 - UNRELEASED YARN-4571. Make app id/name available to the yarn authorizer provider for better auditing. (Jian He via wangda) + YARN-4551. Address the duplication between StatusUpdateWhenHealthy and + StatusUpdateWhenUnhealthy transitions. (Sunil G via kasha) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java index 8448287fe4..3873e5f2f0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java @@ -744,6 +744,20 @@ private static void updateNodeResourceFromEvent(RMNodeImpl rmNode, rmNode.totalCapability = resourceOption.getResource(); } + private static NodeHealthStatus updateRMNodeFromStatusEvents( + RMNodeImpl rmNode, RMNodeStatusEvent statusEvent) { + // Switch the last heartbeatresponse. + rmNode.latestNodeHeartBeatResponse = statusEvent.getLatestResponse(); + NodeHealthStatus remoteNodeHealthStatus = statusEvent.getNodeHealthStatus(); + rmNode.setHealthReport(remoteNodeHealthStatus.getHealthReport()); + rmNode.setLastHealthReportTime(remoteNodeHealthStatus + .getLastHealthReportTime()); + rmNode.setAggregatedContainersUtilization(statusEvent + .getAggregatedContainersUtilization()); + rmNode.setNodeUtilization(statusEvent.getNodeUtilization()); + return remoteNodeHealthStatus; + } + public static class AddNodeTransition implements SingleArcTransition { @@ -1069,17 +1083,8 @@ public NodeState transition(RMNodeImpl rmNode, RMNodeEvent event) { RMNodeStatusEvent statusEvent = (RMNodeStatusEvent) event; - // Switch the last heartbeatresponse. - rmNode.latestNodeHeartBeatResponse = statusEvent.getLatestResponse(); - - NodeHealthStatus remoteNodeHealthStatus = - statusEvent.getNodeHealthStatus(); - rmNode.setHealthReport(remoteNodeHealthStatus.getHealthReport()); - rmNode.setLastHealthReportTime( - remoteNodeHealthStatus.getLastHealthReportTime()); - rmNode.setAggregatedContainersUtilization( - statusEvent.getAggregatedContainersUtilization()); - rmNode.setNodeUtilization(statusEvent.getNodeUtilization()); + NodeHealthStatus remoteNodeHealthStatus = updateRMNodeFromStatusEvents( + rmNode, statusEvent); NodeState initialState = rmNode.getState(); boolean isNodeDecommissioning = initialState.equals(NodeState.DECOMMISSIONING); @@ -1151,15 +1156,8 @@ public NodeState transition(RMNodeImpl rmNode, RMNodeEvent event) { RMNodeStatusEvent statusEvent = (RMNodeStatusEvent)event; // Switch the last heartbeatresponse. - rmNode.latestNodeHeartBeatResponse = statusEvent.getLatestResponse(); - NodeHealthStatus remoteNodeHealthStatus = - statusEvent.getNodeHealthStatus(); - rmNode.setHealthReport(remoteNodeHealthStatus.getHealthReport()); - rmNode.setLastHealthReportTime( - remoteNodeHealthStatus.getLastHealthReportTime()); - rmNode.setAggregatedContainersUtilization( - statusEvent.getAggregatedContainersUtilization()); - rmNode.setNodeUtilization(statusEvent.getNodeUtilization()); + NodeHealthStatus remoteNodeHealthStatus = updateRMNodeFromStatusEvents( + rmNode, statusEvent); if (remoteNodeHealthStatus.getIsNodeHealthy()) { rmNode.context.getDispatcher().getEventHandler().handle( new NodeAddedSchedulerEvent(rmNode));