Skip to content

Commit

Permalink
YARN-686. Flatten NodeReport. (sandyr via tucu)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1490827 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Alejandro Abdelnur committed Jun 7, 2013
1 parent 2a76cdd commit af8514e
Show file tree
Hide file tree
Showing 24 changed files with 168 additions and 163 deletions.
2 changes: 2 additions & 0 deletions hadoop-yarn-project/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -60,7 +60,8 @@ public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
nodeReport.setUsed(used);
nodeReport.setCapability(capability);
nodeReport.setNumContainers(numContainers);
nodeReport.setNodeHealthStatus(nodeHealthStatus);
nodeReport.setHealthReport(healthReport);
nodeReport.setLastHealthReportTime(lastHealthReportTime);
return nodeReport;
}

Expand Down Expand Up @@ -144,15 +145,28 @@ public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
@Unstable
public abstract void setNumContainers(int numContainers);


/**
* Get the <em>diagnostic health report</em> of the node.
* @return <em>diagnostic health report</em> of the node
*/
@Public
@Stable
public abstract String getHealthReport();

@Private
@Unstable
public abstract void setHealthReport(String healthReport);

/**
* Get the <code>NodeHealthStatus</code> of the node.
* @return <code>NodeHealthStatus</code> of the node
* Get the <em>last timestamp</em> at which the health report was received.
* @return <em>last timestamp</em> at which the health report was received
*/
@Public
@Stable
public abstract NodeHealthStatus getNodeHealthStatus();
public abstract long getLastHealthReportTime();

@Private
@Unstable
public abstract void setNodeHealthStatus(NodeHealthStatus nodeHealthStatus);
public abstract void setLastHealthReportTime(long lastHealthReport);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -64,19 +61,33 @@ public Resource getCapability() {
}

@Override
public NodeHealthStatus getNodeHealthStatus() {
if (this.nodeHealthStatus != null) {
return this.nodeHealthStatus;
}

public String getHealthReport() {
NodeReportProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasNodeHealthStatus()) {
return null;
return p.getHealthReport();
}

@Override
public void setHealthReport(String healthReport) {
maybeInitBuilder();
if (healthReport == null) {
builder.clearHealthReport();
return;
}
this.nodeHealthStatus = convertFromProtoFormat(p.getNodeHealthStatus());
return this.nodeHealthStatus;
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;
Expand Down Expand Up @@ -158,14 +169,6 @@ public void setCapability(Resource capability) {
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();
Expand Down Expand Up @@ -247,11 +250,6 @@ private void mergeLocalToBuilder() {
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() {
Expand Down Expand Up @@ -286,11 +284,4 @@ private ResourceProto convertToProtoFormat(Resource r) {
return ((ResourcePBImpl) r).getProto();
}

private NodeHealthStatusPBImpl convertFromProtoFormat(NodeHealthStatusProto p) {
return new NodeHealthStatusPBImpl(p);
}

private NodeHealthStatusProto convertToProtoFormat(NodeHealthStatus r) {
return ((NodeHealthStatusPBImpl) r).getProto();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ public boolean run() throws IOException, YarnException {
+ ", nodeId=" + node.getNodeId()
+ ", nodeAddress" + node.getHttpAddress()
+ ", nodeRackName" + node.getRackName()
+ ", nodeNumContainers" + node.getNumContainers()
+ ", nodeHealthStatus" + node.getNodeHealthStatus());
+ ", nodeNumContainers" + node.getNumContainers());
}

QueueInfo queueInfo = super.getQueueInfo(this.amQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
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 {
Expand Down Expand Up @@ -91,11 +91,10 @@ private void listClusterNodes() throws YarnException, IOException {
List<NodeReport> 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();
Expand Down Expand Up @@ -129,16 +128,13 @@ private void printNodeStatus(String nodeIdStr) throws YarnException,
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 : ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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;
Expand Down Expand Up @@ -163,13 +162,13 @@ public void testListClusterNodes() throws Exception {
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());
Expand All @@ -194,10 +193,9 @@ public void testNodeStatus() throws Exception {
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");
Expand Down Expand Up @@ -246,8 +244,7 @@ private List<NodeReport> getNodeReports(int noOfNodes) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static NodeId newNodeId(String host, int port) {

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);
Expand All @@ -180,7 +180,8 @@ public static NodeReport newNodeReport(NodeId nodeId, NodeState nodeState,
nodeReport.setUsed(used);
nodeReport.setCapability(capability);
nodeReport.setNumContainers(numContainers);
nodeReport.setNodeHealthStatus(nodeHealthStatus);
nodeReport.setHealthReport(healthReport);
nodeReport.setLastHealthReportTime(lastHealthReportTime);
return nodeReport;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ public AllocateResponse allocate(AllocateRequest request)
rmNode.getState(),
rmNode.getHttpAddress(), rmNode.getRackName(), used,
rmNode.getTotalCapability(), numContainers,
rmNode.getNodeHealthStatus());
rmNode.getHealthReport(),
rmNode.getLastHealthReportTime());

updatedNodeReports.add(report);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ private NodeReport createNodeReports(RMNode rmNode) {
rmNode.getState(),
rmNode.getHttpAddress(), rmNode.getRackName(), used,
rmNode.getTotalCapability(), numContainers,
rmNode.getNodeHealthStatus());
rmNode.getHealthReport(),
rmNode.getLastHealthReportTime());

return report;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ public String getLiveNodeManagers() {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit af8514e

Please sign in to comment.