From af8514eef297574240652672d048748100c97733 Mon Sep 17 00:00:00 2001 From: Alejandro Abdelnur Date: Fri, 7 Jun 2013 20:59:23 +0000 Subject: [PATCH] YARN-686. Flatten NodeReport. (sandyr via tucu) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1490827 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 2 + .../hadoop/yarn/api/records/NodeReport.java | 30 +++++++--- .../api/records/impl/pb/NodeReportPBImpl.java | 59 ++++++++----------- .../src/main/proto/yarn_protos.proto | 5 +- .../applications/distributedshell/Client.java | 3 +- .../hadoop/yarn/client/cli/NodeCLI.java | 14 ++--- .../hadoop/yarn/client/cli/TestYarnCLI.java | 15 ++--- .../yarn/server/utils/BuilderUtils.java | 5 +- .../ApplicationMasterService.java | 3 +- .../resourcemanager/ClientRMService.java | 3 +- .../yarn/server/resourcemanager/RMNMInfo.java | 7 +-- .../server/resourcemanager/rmnode/RMNode.java | 12 +++- .../resourcemanager/rmnode/RMNodeImpl.java | 55 ++++++++++++----- .../resourcemanager/webapp/NodesPage.java | 4 +- .../resourcemanager/webapp/RMWebServices.java | 3 +- .../resourcemanager/webapp/dao/NodeInfo.java | 21 +------ .../server/resourcemanager/MockNodes.java | 35 +++++------ .../resourcemanager/TestClientRMService.java | 9 +-- .../TestRMNodeTransitions.java | 5 +- .../resourcemanager/TestResourceManager.java | 7 +-- .../TestResourceTrackerService.java | 9 +-- .../resourcemanager/webapp/TestNodesPage.java | 2 +- .../webapp/TestRMWebServicesNodes.java | 24 +++----- .../hadoop/yarn/server/TestDiskFailures.java | 5 +- 24 files changed, 171 insertions(+), 166 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 137a9f79147..a25dfd0f90c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -301,6 +301,8 @@ Release 2.1.0-beta - UNRELEASED YARN-750. Allow for black-listing resources in YARN API and Impl in CS (acmurthy via bikas) + YARN-686. Flatten NodeReport. (sandyr via tucu) + OPTIMIZATIONS YARN-512. Log aggregation root directory check is more expensive than it diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeReport.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeReport.java index 5f8dc3654e3..494424fb5c2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeReport.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeReport.java @@ -51,7 +51,7 @@ public abstract class NodeReport { @Private public static NodeReport newInstance(NodeId nodeId, NodeState nodeState, String httpAddress, String rackName, Resource used, Resource capability, - int numContainers, NodeHealthStatus nodeHealthStatus) { + int numContainers, String healthReport, long lastHealthReportTime) { NodeReport nodeReport = Records.newRecord(NodeReport.class); nodeReport.setNodeId(nodeId); nodeReport.setNodeState(nodeState); @@ -60,7 +60,8 @@ public abstract class NodeReport { nodeReport.setUsed(used); nodeReport.setCapability(capability); nodeReport.setNumContainers(numContainers); - nodeReport.setNodeHealthStatus(nodeHealthStatus); + nodeReport.setHealthReport(healthReport); + nodeReport.setLastHealthReportTime(lastHealthReportTime); return nodeReport; } @@ -144,15 +145,28 @@ public abstract class NodeReport { @Unstable public abstract void setNumContainers(int numContainers); - /** - * Get the NodeHealthStatus of the node. - * @return NodeHealthStatus of the node + + /** + * Get the diagnostic health report of the node. + * @return diagnostic health report of the node */ @Public @Stable - public abstract NodeHealthStatus getNodeHealthStatus(); - + public abstract String getHealthReport(); + @Private @Unstable - public abstract void setNodeHealthStatus(NodeHealthStatus nodeHealthStatus); + public abstract void setHealthReport(String healthReport); + + /** + * Get the last timestamp at which the health report was received. + * @return last timestamp at which the health report was received + */ + @Public + @Stable + public abstract long getLastHealthReportTime(); + + @Private + @Unstable + public abstract void setLastHealthReportTime(long lastHealthReport); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java index 72b9d436012..8e8f877b567 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java @@ -18,12 +18,10 @@ package org.apache.hadoop.yarn.api.records.impl.pb; -import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeReport; import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProtoOrBuilder; @@ -38,7 +36,6 @@ public class NodeReportPBImpl extends NodeReport { private NodeId nodeId; private Resource used; private Resource capability; - private NodeHealthStatus nodeHealthStatus; public NodeReportPBImpl() { builder = NodeReportProto.newBuilder(); @@ -64,19 +61,33 @@ public class NodeReportPBImpl extends NodeReport { } @Override - public NodeHealthStatus getNodeHealthStatus() { - if (this.nodeHealthStatus != null) { - return this.nodeHealthStatus; - } - + public String getHealthReport() { NodeReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasNodeHealthStatus()) { - return null; - } - this.nodeHealthStatus = convertFromProtoFormat(p.getNodeHealthStatus()); - return this.nodeHealthStatus; + return p.getHealthReport(); } - + + @Override + public void setHealthReport(String healthReport) { + maybeInitBuilder(); + if (healthReport == null) { + builder.clearHealthReport(); + return; + } + builder.setHealthReport(healthReport); + } + + @Override + public long getLastHealthReportTime() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + return p.getLastHealthReportTime(); + } + + @Override + public void setLastHealthReportTime(long lastHealthReportTime) { + maybeInitBuilder(); + builder.setLastHealthReportTime(lastHealthReportTime); + } + @Override public String getHttpAddress() { NodeReportProtoOrBuilder p = viaProto ? proto : builder; @@ -158,14 +169,6 @@ public class NodeReportPBImpl extends NodeReport { this.capability = capability; } - @Override - public void setNodeHealthStatus(NodeHealthStatus healthStatus) { - maybeInitBuilder(); - if (healthStatus == null) - builder.clearNodeHealthStatus(); - this.nodeHealthStatus = healthStatus; - } - @Override public void setHttpAddress(String httpAddress) { maybeInitBuilder(); @@ -247,11 +250,6 @@ public class NodeReportPBImpl extends NodeReport { builder.getCapability())) { builder.setCapability(convertToProtoFormat(this.capability)); } - if (this.nodeHealthStatus != null - && !((NodeHealthStatusPBImpl) this.nodeHealthStatus).getProto().equals( - builder.getNodeHealthStatus())) { - builder.setNodeHealthStatus(convertToProtoFormat(this.nodeHealthStatus)); - } } private void mergeLocalToProto() { @@ -286,11 +284,4 @@ public class NodeReportPBImpl extends NodeReport { return ((ResourcePBImpl) r).getProto(); } - private NodeHealthStatusPBImpl convertFromProtoFormat(NodeHealthStatusProto p) { - return new NodeHealthStatusPBImpl(p); - } - - private NodeHealthStatusProto convertToProtoFormat(NodeHealthStatus r) { - return ((NodeHealthStatusPBImpl) r).getProto(); - } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index fa6057d3365..504bc5c2f24 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -191,8 +191,9 @@ message NodeReportProto { optional ResourceProto used = 4; optional ResourceProto capability = 5; optional int32 numContainers = 6; - optional NodeHealthStatusProto node_health_status = 8; - optional NodeStateProto node_state = 9; + optional NodeStateProto node_state = 7; + optional string health_report = 8; + optional int64 last_health_report_time = 9; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java index 4c1a23e9ebc..cec24c29ea8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java @@ -330,8 +330,7 @@ public class Client extends YarnClientImpl { + ", nodeId=" + node.getNodeId() + ", nodeAddress" + node.getHttpAddress() + ", nodeRackName" + node.getRackName() - + ", nodeNumContainers" + node.getNumContainers() - + ", nodeHealthStatus" + node.getNodeHealthStatus()); + + ", nodeNumContainers" + node.getNumContainers()); } QueueInfo queueInfo = super.getQueueInfo(this.amQueue); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java index b701d214b67..d8c05a8b210 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java @@ -35,7 +35,7 @@ import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.util.ConverterUtils; public class NodeCLI extends YarnCLI { - private static final String NODES_PATTERN = "%16s\t%10s\t%17s\t%26s\t%18s" + + private static final String NODES_PATTERN = "%16s\t%10s\t%17s\t%18s" + System.getProperty("line.separator"); public static void main(String[] args) throws Exception { @@ -91,11 +91,10 @@ public class NodeCLI extends YarnCLI { List nodesReport = client.getNodeReports(); writer.println("Total Nodes:" + nodesReport.size()); writer.printf(NODES_PATTERN, "Node-Id", "Node-State", "Node-Http-Address", - "Health-Status(isNodeHealthy)", "Running-Containers"); + "Running-Containers"); for (NodeReport nodeReport : nodesReport) { writer.printf(NODES_PATTERN, nodeReport.getNodeId(), nodeReport .getNodeState(), nodeReport.getHttpAddress(), nodeReport - .getNodeHealthStatus().getIsNodeHealthy(), nodeReport .getNumContainers()); } writer.flush(); @@ -129,16 +128,13 @@ public class NodeCLI extends YarnCLI { nodeReportStr.println(nodeReport.getNodeState()); nodeReportStr.print("\tNode-Http-Address : "); nodeReportStr.println(nodeReport.getHttpAddress()); - nodeReportStr.print("\tHealth-Status(isNodeHealthy) : "); - nodeReportStr.println(nodeReport.getNodeHealthStatus() - .getIsNodeHealthy()); nodeReportStr.print("\tLast-Health-Update : "); nodeReportStr.println(DateFormatUtils.format( - new Date(nodeReport.getNodeHealthStatus(). - getLastHealthReportTime()),"E dd/MMM/yy hh:mm:ss:SSzz")); + new Date(nodeReport.getLastHealthReportTime()), + "E dd/MMM/yy hh:mm:ss:SSzz")); nodeReportStr.print("\tHealth-Report : "); nodeReportStr - .println(nodeReport.getNodeHealthStatus().getHealthReport()); + .println(nodeReport.getHealthReport()); nodeReportStr.print("\tContainers : "); nodeReportStr.println(nodeReport.getNumContainers()); nodeReportStr.print("\tMemory-Used : "); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java index 137ca484fae..49d78677673 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java @@ -41,7 +41,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeReport; import org.apache.hadoop.yarn.api.records.NodeState; @@ -163,13 +162,13 @@ public class TestYarnCLI { PrintWriter pw = new PrintWriter(baos); pw.println("Total Nodes:3"); pw.print(" Node-Id\tNode-State\tNode-Http-Address\t"); - pw.println("Health-Status(isNodeHealthy)\tRunning-Containers"); + pw.println("Running-Containers"); pw.print(" host0:0\t RUNNING\t host1:8888"); - pw.println("\t false\t 0"); + pw.println("\t 0"); pw.print(" host1:0\t RUNNING\t host1:8888"); - pw.println("\t false\t 0"); + pw.println("\t 0"); pw.print(" host2:0\t RUNNING\t host1:8888"); - pw.println("\t false\t 0"); + pw.println("\t 0"); pw.close(); String nodesReportStr = baos.toString("UTF-8"); Assert.assertEquals(nodesReportStr, sysOutStream.toString()); @@ -194,10 +193,9 @@ public class TestYarnCLI { pw.println("\tRack : rack1"); pw.println("\tNode-State : RUNNING"); pw.println("\tNode-Http-Address : host1:8888"); - pw.println("\tHealth-Status(isNodeHealthy) : false"); pw.println("\tLast-Health-Update : " + DateFormatUtils.format(new Date(0), "E dd/MMM/yy hh:mm:ss:SSzz")); - pw.println("\tHealth-Report : null"); + pw.println("\tHealth-Report : "); pw.println("\tContainers : 0"); pw.println("\tMemory-Used : 0M"); pw.println("\tMemory-Capacity : 0"); @@ -246,8 +244,7 @@ public class TestYarnCLI { NodeReport nodeReport = NodeReport.newInstance(NodeId .newInstance("host" + i, 0), NodeState.RUNNING, "host" + 1 + ":8888", "rack1", Records.newRecord(Resource.class), Records - .newRecord(Resource.class), 0, Records - .newRecord(NodeHealthStatus.class)); + .newRecord(Resource.class), 0, "", 0); nodeReports.add(nodeReport); } return nodeReports; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java index 438dd70a719..46a385b9ece 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java @@ -171,7 +171,7 @@ public class BuilderUtils { public static NodeReport newNodeReport(NodeId nodeId, NodeState nodeState, String httpAddress, String rackName, Resource used, Resource capability, - int numContainers, NodeHealthStatus nodeHealthStatus) { + int numContainers, String healthReport, long lastHealthReportTime) { NodeReport nodeReport = recordFactory.newRecordInstance(NodeReport.class); nodeReport.setNodeId(nodeId); nodeReport.setNodeState(nodeState); @@ -180,7 +180,8 @@ public class BuilderUtils { nodeReport.setUsed(used); nodeReport.setCapability(capability); nodeReport.setNumContainers(numContainers); - nodeReport.setNodeHealthStatus(nodeHealthStatus); + nodeReport.setHealthReport(healthReport); + nodeReport.setLastHealthReportTime(lastHealthReportTime); return nodeReport; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java index c279a9c80c4..d71c1de3428 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java @@ -343,7 +343,8 @@ public class ApplicationMasterService extends AbstractService implements rmNode.getState(), rmNode.getHttpAddress(), rmNode.getRackName(), used, rmNode.getTotalCapability(), numContainers, - rmNode.getNodeHealthStatus()); + rmNode.getHealthReport(), + rmNode.getLastHealthReportTime()); updatedNodeReports.add(report); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java index f1459fa7dac..35c3a073347 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java @@ -475,7 +475,8 @@ public class ClientRMService extends AbstractService implements rmNode.getState(), rmNode.getHttpAddress(), rmNode.getRackName(), used, rmNode.getTotalCapability(), numContainers, - rmNode.getNodeHealthStatus()); + rmNode.getHealthReport(), + rmNode.getLastHealthReportTime()); return report; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java index 0db42e40ec0..5f7002ce4b1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java @@ -86,13 +86,10 @@ public class RMNMInfo implements RMNMInfoBeans { info.put("State", ni.getState().toString()); info.put("NodeId", ni.getNodeID()); info.put("NodeHTTPAddress", ni.getHttpAddress()); - info.put("HealthStatus", - ni.getNodeHealthStatus().getIsNodeHealthy() ? - "Healthy" : "Unhealthy"); info.put("LastHealthUpdate", - ni.getNodeHealthStatus().getLastHealthReportTime()); + ni.getLastHealthReportTime()); info.put("HealthReport", - ni.getNodeHealthStatus().getHealthReport()); + ni.getHealthReport()); if(report != null) { info.put("NumContainers", report.getNumContainers()); info.put("UsedMemoryMB", report.getUsedResource().getMemory()); 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/RMNode.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java index 82986702601..3652030807b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java @@ -74,10 +74,16 @@ public interface RMNode { public String getHttpAddress(); /** - * the health-status for this node - * @return the health-status for this node. + * the latest health report received from this node. + * @return the latest health report received from this node. */ - public NodeHealthStatus getNodeHealthStatus(); + public String getHealthReport(); + + /** + * the time of the latest health report received from this node. + * @return the time of the latest health report received from this node. + */ + public long getLastHealthReportTime(); /** * the total available resource. 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 252fb75e323..c671c8877ac 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 @@ -93,9 +93,10 @@ public class RMNodeImpl implements RMNode, EventHandler { private final String httpAddress; private final Resource totalCapability; private final Node node; - private final NodeHealthStatus nodeHealthStatus = recordFactory - .newRecordInstance(NodeHealthStatus.class); - + + private String healthReport; + private long lastHealthReportTime; + /* set of containers that have just launched */ private final Map justLaunchedContainers = new HashMap(); @@ -180,9 +181,8 @@ public class RMNodeImpl implements RMNode, EventHandler { this.nodeAddress = hostName + ":" + cmPort; this.httpAddress = hostName + ":" + httpPort; this.node = node; - this.nodeHealthStatus.setIsNodeHealthy(true); - this.nodeHealthStatus.setHealthReport("Healthy"); - this.nodeHealthStatus.setLastHealthReportTime(System.currentTimeMillis()); + this.healthReport = "Healthy"; + this.lastHealthReportTime = System.currentTimeMillis(); this.latestNodeHeartBeatResponse.setResponseId(0); @@ -246,27 +246,46 @@ public class RMNodeImpl implements RMNode, EventHandler { } @Override - public NodeHealthStatus getNodeHealthStatus() { + public String getHealthReport() { this.readLock.lock(); try { - return this.nodeHealthStatus; + return this.healthReport; } finally { this.readLock.unlock(); } } - - private void setNodeHealthStatus(NodeHealthStatus status) - { + + public void setHealthReport(String healthReport) { this.writeLock.lock(); + try { - this.nodeHealthStatus.setHealthReport(status.getHealthReport()); - this.nodeHealthStatus.setIsNodeHealthy(status.getIsNodeHealthy()); - this.nodeHealthStatus.setLastHealthReportTime(status.getLastHealthReportTime()); + this.healthReport = healthReport; } finally { this.writeLock.unlock(); } } + + public void setLastHealthReportTime(long lastHealthReportTime) { + this.writeLock.lock(); + + try { + this.lastHealthReportTime = lastHealthReportTime; + } finally { + this.writeLock.unlock(); + } + } + + @Override + public long getLastHealthReportTime() { + this.readLock.lock(); + + try { + return this.lastHealthReportTime; + } finally { + this.readLock.unlock(); + } + } @Override public NodeState getState() { @@ -511,7 +530,9 @@ public class RMNodeImpl implements RMNode, EventHandler { NodeHealthStatus remoteNodeHealthStatus = statusEvent.getNodeHealthStatus(); - rmNode.setNodeHealthStatus(remoteNodeHealthStatus); + rmNode.setHealthReport(remoteNodeHealthStatus.getHealthReport()); + rmNode.setLastHealthReportTime( + remoteNodeHealthStatus.getLastHealthReportTime()); if (!remoteNodeHealthStatus.getIsNodeHealthy()) { LOG.info("Node " + rmNode.nodeId + " reported UNHEALTHY with details: " + remoteNodeHealthStatus.getHealthReport()); @@ -593,7 +614,9 @@ public class RMNodeImpl implements RMNode, EventHandler { // Switch the last heartbeatresponse. rmNode.latestNodeHeartBeatResponse = statusEvent.getLatestResponse(); NodeHealthStatus remoteNodeHealthStatus = statusEvent.getNodeHealthStatus(); - rmNode.setNodeHealthStatus(remoteNodeHealthStatus); + rmNode.setHealthReport(remoteNodeHealthStatus.getHealthReport()); + rmNode.setLastHealthReportTime( + remoteNodeHealthStatus.getLastHealthReportTime()); if (remoteNodeHealthStatus.getIsNodeHealthy()) { rmNode.context.getDispatcher().getEventHandler().handle( new NodeAddedSchedulerEvent(rmNode)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java index 18167c89ccb..493fbad2cf6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java @@ -71,7 +71,6 @@ class NodesPage extends RmView { th(".state", "Node State"). th(".nodeaddress", "Node Address"). th(".nodehttpaddress", "Node HTTP Address"). - th(".healthStatus", "Health-status"). th(".lastHealthUpdate", "Last health-update"). th(".healthReport", "Health-report"). th(".containers", "Containers"). @@ -122,8 +121,7 @@ class NodesPage extends RmView { row.td().a(HttpConfig.getSchemePrefix() + httpAddress, httpAddress)._(); } - row.td(info.getHealthStatus()). - td().br().$title(String.valueOf(info.getLastHealthUpdate()))._(). + row.td().br().$title(String.valueOf(info.getLastHealthUpdate()))._(). _(Times.format(info.getLastHealthUpdate()))._(). td(info.getHealthReport()). td(String.valueOf(info.getNumContainers())). diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java index e2efdd7454e..b769c2169cd 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java @@ -196,7 +196,8 @@ public class RMWebServices { String msg = "Error: You must specify either true or false to query on health"; throw new BadRequestException(msg); } - if (nodeInfo.isHealthy() != Boolean.parseBoolean(healthState)) { + if ((ni.getState() != NodeState.UNHEALTHY) + != Boolean.parseBoolean(healthState)) { continue; } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java index c8e7b9ba387..99506f33a0d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java @@ -21,9 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; -import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode; @@ -39,23 +37,18 @@ public class NodeInfo { protected String id; protected String nodeHostName; protected String nodeHTTPAddress; - protected String healthStatus; protected long lastHealthUpdate; protected String healthReport; protected int numContainers; protected long usedMemoryMB; protected long availMemoryMB; - @XmlTransient - protected boolean healthy; - public NodeInfo() { } // JAXB needs this public NodeInfo(RMNode ni, ResourceScheduler sched) { NodeId id = ni.getNodeID(); SchedulerNodeReport report = sched.getNodeReport(id); - NodeHealthStatus health = ni.getNodeHealthStatus(); this.numContainers = 0; this.usedMemoryMB = 0; this.availMemoryMB = 0; @@ -69,14 +62,8 @@ public class NodeInfo { this.nodeHostName = ni.getHostName(); this.state = ni.getState(); this.nodeHTTPAddress = ni.getHttpAddress(); - this.healthy = health.getIsNodeHealthy(); - this.healthStatus = health.getIsNodeHealthy() ? "Healthy" : "Unhealthy"; - this.lastHealthUpdate = health.getLastHealthReportTime(); - this.healthReport = String.valueOf(health.getHealthReport()); - } - - public boolean isHealthy() { - return this.healthy; + this.lastHealthUpdate = ni.getLastHealthReportTime(); + this.healthReport = String.valueOf(ni.getHealthReport()); } public String getRack() { @@ -99,10 +86,6 @@ public class NodeInfo { this.nodeHTTPAddress = nodeHTTPAddress; } - public String getHealthStatus() { - return this.healthStatus; - } - public long getLastHealthUpdate() { return this.lastHealthUpdate; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java index 53402b4e73a..83b81a18504 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java @@ -24,7 +24,6 @@ import java.util.List; import org.apache.hadoop.net.Node; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.Resource; @@ -96,18 +95,20 @@ public class MockNodes { private int cmdPort; private Resource perNode; private String rackName; - private NodeHealthStatus nodeHealthStatus; + private String healthReport; + private long lastHealthReportTime; private NodeState state; public MockRMNodeImpl(NodeId nodeId, String nodeAddr, String httpAddress, - Resource perNode, String rackName, NodeHealthStatus nodeHealthStatus, - int cmdPort, String hostName, NodeState state) { + Resource perNode, String rackName, String healthReport, + long lastHealthReportTime, int cmdPort, String hostName, NodeState state) { this.nodeId = nodeId; this.nodeAddr = nodeAddr; this.httpAddress = httpAddress; this.perNode = perNode; this.rackName = rackName; - this.nodeHealthStatus = nodeHealthStatus; + this.healthReport = healthReport; + this.lastHealthReportTime = lastHealthReportTime; this.cmdPort = cmdPort; this.hostName = hostName; this.state = state; @@ -143,11 +144,6 @@ public class MockNodes { return this.httpAddress; } - @Override - public NodeHealthStatus getNodeHealthStatus() { - return this.nodeHealthStatus; - } - @Override public Resource getTotalCapability() { return this.perNode; @@ -191,6 +187,16 @@ public class MockNodes { public List pullContainerUpdates() { return new ArrayList(); } + + @Override + public String getHealthReport() { + return healthReport; + } + + @Override + public long getLastHealthReportTime() { + return lastHealthReportTime; + } }; private static RMNode buildRMNode(int rack, final Resource perNode, NodeState state, String httpAddr) { @@ -209,14 +215,9 @@ public class MockNodes { final NodeId nodeID = NodeId.newInstance(hostName, port); final String httpAddress = httpAddr; - final NodeHealthStatus nodeHealthStatus = - recordFactory.newRecordInstance(NodeHealthStatus.class); - if (state != NodeState.UNHEALTHY) { - nodeHealthStatus.setIsNodeHealthy(true); - nodeHealthStatus.setHealthReport("HealthyMe"); - } + String healthReport = (state == NodeState.UNHEALTHY) ? null : "HealthyMe"; return new MockRMNodeImpl(nodeID, nodeAddr, httpAddress, perNode, rackName, - nodeHealthStatus, nid, hostName, state); + healthReport, 0, nid, hostName, state); } public static RMNode nodeInfo(int rack, final Resource perNode, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java index d819467a9c2..75b0a9e5f4b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java @@ -53,6 +53,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.NodeReport; +import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -133,8 +134,8 @@ public class TestClientRMService { List nodeReports = client.getClusterNodes(request).getNodeReports(); Assert.assertEquals(1, nodeReports.size()); - Assert.assertTrue("Node is expected to be healthy!", nodeReports.get(0) - .getNodeHealthStatus().getIsNodeHealthy()); + Assert.assertNotSame("Node is expected to be healthy!", NodeState.UNHEALTHY, + nodeReports.get(0).getNodeState()); // Now make the node unhealthy. node.nodeHeartbeat(false); @@ -142,8 +143,8 @@ public class TestClientRMService { // Call again nodeReports = client.getClusterNodes(request).getNodeReports(); Assert.assertEquals(1, nodeReports.size()); - Assert.assertFalse("Node is expected to be unhealthy!", nodeReports.get(0) - .getNodeHealthStatus().getIsNodeHealthy()); + Assert.assertEquals("Node is expected to be unhealthy!", NodeState.UNHEALTHY, + nodeReports.get(0).getNodeState()); } @Test diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java index f7f71fd9943..56c5119af07 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java @@ -346,9 +346,8 @@ public class TestRMNodeTransitions { private RMNodeImpl getUnhealthyNode() { RMNodeImpl node = getRunningNode(); - NodeHealthStatus status = node.getNodeHealthStatus(); - status.setHealthReport("sick"); - status.setIsNodeHealthy(false); + NodeHealthStatus status = NodeHealthStatus.newInstance(false, "sick", + System.currentTimeMillis()); node.handle(new RMNodeStatusEvent(node.getNodeID(), status, new ArrayList(), null, null)); Assert.assertEquals(NodeState.UNHEALTHY, node.getState()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceManager.java index ffe8c811a54..cf4dc674ac9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceManager.java @@ -176,11 +176,8 @@ public class TestResourceManager { nm1.heartbeat(); nm1.heartbeat(); Collection values = resourceManager.getRMContext().getRMNodes().values(); - for (RMNode ni : values) - { - NodeHealthStatus nodeHealthStatus = ni.getNodeHealthStatus(); - String healthReport = nodeHealthStatus.getHealthReport(); - assertNotNull(healthReport); + for (RMNode ni : values) { + assertNotNull(ni.getHealthReport()); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java index e34a40d3b1d..fbc710427ad 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java @@ -32,6 +32,7 @@ import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.event.Dispatcher; @@ -391,15 +392,15 @@ public class TestResourceTrackerService { int count) throws Exception { int waitCount = 0; - while(rm.getRMContext().getRMNodes().get(nm1.getNodeId()) - .getNodeHealthStatus().getIsNodeHealthy() == health + while((rm.getRMContext().getRMNodes().get(nm1.getNodeId()) + .getState() != NodeState.UNHEALTHY) == health && waitCount++ < 20) { synchronized (this) { wait(100); } } - Assert.assertFalse(rm.getRMContext().getRMNodes().get(nm1.getNodeId()) - .getNodeHealthStatus().getIsNodeHealthy() == health); + Assert.assertFalse((rm.getRMContext().getRMNodes().get(nm1.getNodeId()) + .getState() != NodeState.UNHEALTHY) == health); Assert.assertEquals("Unhealthy metrics not incremented", count, ClusterMetrics.getMetrics().getUnhealthyNMs()); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java index 1979273ce12..6cd5a02f182 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java @@ -49,7 +49,7 @@ public class TestNodesPage { // Number of Actual Table Headers for NodesPage.NodesBlock might change in // future. In that case this value should be adjusted to the new value. final int numberOfThInMetricsTable = 13; - final int numberOfActualTableHeaders = 10; + final int numberOfActualTableHeaders = 9; private Injector injector; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java index 533ea11b68b..44041389454 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java @@ -142,9 +142,8 @@ public class TestRMWebServicesNodes extends JerseyTest { rm.NMwaitForState(nm3.getNodeId(), NodeState.RUNNING); RMNodeImpl node = (RMNodeImpl) rm.getRMContext().getRMNodes() .get(nm3.getNodeId()); - NodeHealthStatus nodeHealth = node.getNodeHealthStatus(); - nodeHealth.setHealthReport("test health report"); - nodeHealth.setIsNodeHealthy(false); + NodeHealthStatus nodeHealth = NodeHealthStatus.newInstance(false, + "test health report", System.currentTimeMillis()); node.handle(new RMNodeStatusEvent(nm3.getNodeId(), nodeHealth, new ArrayList(), null, null)); rm.NMwaitForState(nm3.getNodeId(), NodeState.UNHEALTHY); @@ -357,9 +356,8 @@ public class TestRMWebServicesNodes extends JerseyTest { rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); RMNodeImpl node = (RMNodeImpl) rm.getRMContext().getRMNodes() .get(nm1.getNodeId()); - NodeHealthStatus nodeHealth = node.getNodeHealthStatus(); - nodeHealth.setHealthReport("test health report"); - nodeHealth.setIsNodeHealthy(false); + NodeHealthStatus nodeHealth = NodeHealthStatus.newInstance(false, + "test health report", System.currentTimeMillis()); node.handle(new RMNodeStatusEvent(nm1.getNodeId(), nodeHealth, new ArrayList(), null, null)); rm.NMwaitForState(nm1.getNodeId(), NodeState.UNHEALTHY); @@ -699,7 +697,6 @@ public class TestRMWebServicesNodes extends JerseyTest { verifyNodeInfoGeneric(nm, WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlString(element, "rack"), - WebServicesTestUtils.getXmlString(element, "healthStatus"), WebServicesTestUtils.getXmlString(element, "id"), WebServicesTestUtils.getXmlString(element, "nodeHostName"), WebServicesTestUtils.getXmlString(element, "nodeHTTPAddress"), @@ -713,10 +710,10 @@ public class TestRMWebServicesNodes extends JerseyTest { public void verifyNodeInfo(JSONObject nodeInfo, MockNM nm) throws JSONException, Exception { - assertEquals("incorrect number of elements", 11, nodeInfo.length()); + assertEquals("incorrect number of elements", 10, nodeInfo.length()); verifyNodeInfoGeneric(nm, nodeInfo.getString("state"), - nodeInfo.getString("rack"), nodeInfo.getString("healthStatus"), + nodeInfo.getString("rack"), nodeInfo.getString("id"), nodeInfo.getString("nodeHostName"), nodeInfo.getString("nodeHTTPAddress"), nodeInfo.getLong("lastHealthUpdate"), @@ -726,32 +723,29 @@ public class TestRMWebServicesNodes extends JerseyTest { } public void verifyNodeInfoGeneric(MockNM nm, String state, String rack, - String healthStatus, String id, String nodeHostName, + String id, String nodeHostName, String nodeHTTPAddress, long lastHealthUpdate, String healthReport, int numContainers, long usedMemoryMB, long availMemoryMB) throws JSONException, Exception { RMNode node = rm.getRMContext().getRMNodes().get(nm.getNodeId()); - NodeHealthStatus health = node.getNodeHealthStatus(); ResourceScheduler sched = rm.getResourceScheduler(); SchedulerNodeReport report = sched.getNodeReport(nm.getNodeId()); WebServicesTestUtils.checkStringMatch("state", node.getState().toString(), state); WebServicesTestUtils.checkStringMatch("rack", node.getRackName(), rack); - WebServicesTestUtils.checkStringMatch("healthStatus", "Healthy", - healthStatus); WebServicesTestUtils.checkStringMatch("id", nm.getNodeId().toString(), id); WebServicesTestUtils.checkStringMatch("nodeHostName", nm.getNodeId() .getHost(), nodeHostName); WebServicesTestUtils.checkStringMatch("healthReport", - String.valueOf(health.getHealthReport()), healthReport); + String.valueOf(node.getHealthReport()), healthReport); String expectedHttpAddress = nm.getNodeId().getHost() + ":" + nm.getHttpPort(); WebServicesTestUtils.checkStringMatch("nodeHTTPAddress", expectedHttpAddress, nodeHTTPAddress); - long expectedHealthUpdate = health.getLastHealthReportTime(); + long expectedHealthUpdate = node.getLastHealthReportTime(); assertEquals("lastHealthUpdate doesn't match, got: " + lastHealthUpdate + " expected: " + expectedHealthUpdate, expectedHealthUpdate, lastHealthUpdate); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java index eab19634734..b81cacb80e2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java @@ -27,6 +27,7 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.UnsupportedFileSystemException; import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.util.StringUtils; +import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.MiniYARNCluster; import org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService; @@ -243,7 +244,7 @@ public class TestDiskFailures { for (int i = 0; i < 10; i++) { Iterator iter = yarnCluster.getResourceManager().getRMContext() .getRMNodes().values().iterator(); - if (iter.next().getNodeHealthStatus().getIsNodeHealthy() == isHealthy) { + if ((iter.next().getState() != NodeState.UNHEALTHY) == isHealthy) { break; } // wait for the node health info to go to RM @@ -256,7 +257,7 @@ public class TestDiskFailures { Iterator iter = yarnCluster.getResourceManager().getRMContext() .getRMNodes().values().iterator(); Assert.assertEquals("RM is not updated with the health status of a node", - isHealthy, iter.next().getNodeHealthStatus().getIsNodeHealthy()); + isHealthy, iter.next().getState() != NodeState.UNHEALTHY); } /**