MAPREDUCE-2990. Fixed display of NodeHealthStatus. Contributed by Subroto Sanyal.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1175351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arun Murthy 2011-09-25 09:36:12 +00:00
parent d09ceac1f7
commit 5ace0cabe5
3 changed files with 44 additions and 3 deletions

View File

@ -1409,6 +1409,9 @@ Release 0.23.0 - Unreleased
MAPREDUCE-2691. Increase threadpool size for launching containers in
MapReduce ApplicationMaster. (vinodkv via acmurthy)
MAPREDUCE-2990. Fixed display of NodeHealthStatus. (Subroto Sanyal via
acmurthy)
Release 0.22.0 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -147,6 +147,7 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
this.httpAddress = hostName + ":" + httpPort;;
this.node = node;
this.nodeHealthStatus.setIsNodeHealthy(true);
this.nodeHealthStatus.setHealthReport("Healthy");
this.nodeHealthStatus.setLastHealthReportTime(System.currentTimeMillis());
this.latestHeartBeatResponse.setResponseId(0);
@ -222,6 +223,18 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
}
}
private void setNodeHealthStatus(NodeHealthStatus status)
{
this.writeLock.lock();
try {
this.nodeHealthStatus.setHealthReport(status.getHealthReport());
this.nodeHealthStatus.setIsNodeHealthy(status.getIsNodeHealthy());
this.nodeHealthStatus.setLastHealthReportTime(status.getLastHealthReportTime());
} finally {
this.writeLock.unlock();
}
}
@Override
public RMNodeState getState() {
this.readLock.lock();
@ -345,7 +358,10 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
// Switch the last heartbeatresponse.
rmNode.latestHeartBeatResponse = statusEvent.getLatestResponse();
if (!statusEvent.getNodeHealthStatus().getIsNodeHealthy()) {
NodeHealthStatus remoteNodeHealthStatus =
statusEvent.getNodeHealthStatus();
rmNode.setNodeHealthStatus(remoteNodeHealthStatus);
if (!remoteNodeHealthStatus.getIsNodeHealthy()) {
// Inform the scheduler
rmNode.context.getDispatcher().getEventHandler().handle(
new NodeRemovedSchedulerEvent(rmNode));
@ -392,8 +408,9 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
// Switch the last heartbeatresponse.
rmNode.latestHeartBeatResponse = statusEvent.getLatestResponse();
if (statusEvent.getNodeHealthStatus().getIsNodeHealthy()) {
NodeHealthStatus remoteNodeHealthStatus = statusEvent.getNodeHealthStatus();
rmNode.setNodeHealthStatus(remoteNodeHealthStatus);
if (remoteNodeHealthStatus.getIsNodeHealthy()) {
rmNode.context.getDispatcher().getEventHandler().handle(
new NodeAddedSchedulerEvent(rmNode));
return RMNodeState.RUNNING;

View File

@ -18,12 +18,16 @@
package org.apache.hadoop.yarn.server.resourcemanager;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.net.NetworkTopology;
import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store;
@ -153,6 +157,23 @@ public class TestResourceManager {
LOG.info("--- END: testResourceAllocation ---");
}
@Test
public void testNodeHealthReportIsNotNull() throws Exception{
String host1 = "host1";
final int memory = 4 * 1024;
org.apache.hadoop.yarn.server.resourcemanager.NodeManager nm1 =
registerNode(host1, 1234, 2345, NetworkTopology.DEFAULT_RACK, memory);
nm1.heartbeat();
nm1.heartbeat();
Collection<RMNode> values = resourceManager.getRMContext().getRMNodes().values();
for (RMNode ni : values)
{
NodeHealthStatus nodeHealthStatus = ni.getNodeHealthStatus();
String healthReport = nodeHealthStatus.getHealthReport();
assertNotNull(healthReport);
}
}
private void checkResourceUsage(
org.apache.hadoop.yarn.server.resourcemanager.NodeManager... nodes ) {