YARN-390. Merge r1449980 from trunk.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1449986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c9ceb03b2
commit
dbb624ed74
|
@ -24,6 +24,9 @@ Release 2.0.4-beta - UNRELEASED
|
||||||
YARN-391. Formatting fixes for LCEResourceHandler classes.
|
YARN-391. Formatting fixes for LCEResourceHandler classes.
|
||||||
(Steve Loughran via sseth)
|
(Steve Loughran via sseth)
|
||||||
|
|
||||||
|
YARN-390. ApplicationCLI and NodeCLI hard-coded platform-specific line
|
||||||
|
separator causes test failures on Windows. (Chris Nauroth via suresh)
|
||||||
|
|
||||||
Release 2.0.3-alpha - 2013-02-06
|
Release 2.0.3-alpha - 2013-02-06
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.yarn.client.cli;
|
package org.apache.hadoop.yarn.client.cli;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -31,7 +33,9 @@ import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
|
||||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||||
|
|
||||||
public class ApplicationCLI extends YarnCLI {
|
public class ApplicationCLI extends YarnCLI {
|
||||||
private static final String APPLICATIONS_PATTERN = "%30s\t%20s\t%10s\t%10s\t%18s\t%18s\t%35s\n";
|
private static final String APPLICATIONS_PATTERN =
|
||||||
|
"%30s\t%20s\t%10s\t%10s\t%18s\t%18s\t%35s" +
|
||||||
|
System.getProperty("line.separator");
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ApplicationCLI cli = new ApplicationCLI();
|
ApplicationCLI cli = new ApplicationCLI();
|
||||||
|
@ -123,37 +127,40 @@ public class ApplicationCLI extends YarnCLI {
|
||||||
* @throws YarnRemoteException
|
* @throws YarnRemoteException
|
||||||
*/
|
*/
|
||||||
private void printApplicationReport(String applicationId)
|
private void printApplicationReport(String applicationId)
|
||||||
throws YarnRemoteException {
|
throws YarnRemoteException, IOException {
|
||||||
ApplicationReport appReport = client.getApplicationReport(ConverterUtils
|
ApplicationReport appReport = client.getApplicationReport(ConverterUtils
|
||||||
.toApplicationId(applicationId));
|
.toApplicationId(applicationId));
|
||||||
StringBuffer appReportStr = new StringBuffer();
|
// Use PrintWriter.println, which uses correct platform line ending.
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
PrintWriter appReportStr = new PrintWriter(baos);
|
||||||
if (appReport != null) {
|
if (appReport != null) {
|
||||||
appReportStr.append("Application Report : ");
|
appReportStr.println("Application Report : ");
|
||||||
appReportStr.append("\n\tApplication-Id : ");
|
appReportStr.print("\tApplication-Id : ");
|
||||||
appReportStr.append(appReport.getApplicationId());
|
appReportStr.println(appReport.getApplicationId());
|
||||||
appReportStr.append("\n\tApplication-Name : ");
|
appReportStr.print("\tApplication-Name : ");
|
||||||
appReportStr.append(appReport.getName());
|
appReportStr.println(appReport.getName());
|
||||||
appReportStr.append("\n\tUser : ");
|
appReportStr.print("\tUser : ");
|
||||||
appReportStr.append(appReport.getUser());
|
appReportStr.println(appReport.getUser());
|
||||||
appReportStr.append("\n\tQueue : ");
|
appReportStr.print("\tQueue : ");
|
||||||
appReportStr.append(appReport.getQueue());
|
appReportStr.println(appReport.getQueue());
|
||||||
appReportStr.append("\n\tStart-Time : ");
|
appReportStr.print("\tStart-Time : ");
|
||||||
appReportStr.append(appReport.getStartTime());
|
appReportStr.println(appReport.getStartTime());
|
||||||
appReportStr.append("\n\tFinish-Time : ");
|
appReportStr.print("\tFinish-Time : ");
|
||||||
appReportStr.append(appReport.getFinishTime());
|
appReportStr.println(appReport.getFinishTime());
|
||||||
appReportStr.append("\n\tState : ");
|
appReportStr.print("\tState : ");
|
||||||
appReportStr.append(appReport.getYarnApplicationState());
|
appReportStr.println(appReport.getYarnApplicationState());
|
||||||
appReportStr.append("\n\tFinal-State : ");
|
appReportStr.print("\tFinal-State : ");
|
||||||
appReportStr.append(appReport.getFinalApplicationStatus());
|
appReportStr.println(appReport.getFinalApplicationStatus());
|
||||||
appReportStr.append("\n\tTracking-URL : ");
|
appReportStr.print("\tTracking-URL : ");
|
||||||
appReportStr.append(appReport.getOriginalTrackingUrl());
|
appReportStr.println(appReport.getOriginalTrackingUrl());
|
||||||
appReportStr.append("\n\tDiagnostics : ");
|
appReportStr.print("\tDiagnostics : ");
|
||||||
appReportStr.append(appReport.getDiagnostics());
|
appReportStr.print(appReport.getDiagnostics());
|
||||||
} else {
|
} else {
|
||||||
appReportStr.append("Application with id '" + applicationId
|
appReportStr.print("Application with id '" + applicationId
|
||||||
+ "' doesn't exist in RM.");
|
+ "' doesn't exist in RM.");
|
||||||
}
|
}
|
||||||
sysout.println(appReportStr.toString());
|
appReportStr.close();
|
||||||
|
sysout.println(baos.toString("UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.yarn.client.cli;
|
package org.apache.hadoop.yarn.client.cli;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -31,7 +33,9 @@ import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
|
||||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||||
|
|
||||||
public class NodeCLI extends YarnCLI {
|
public class NodeCLI extends YarnCLI {
|
||||||
private static final String NODES_PATTERN = "%16s\t%10s\t%17s\t%26s\t%18s\n";
|
private static final String NODES_PATTERN = "%16s\t%10s\t%17s\t%26s\t%18s" +
|
||||||
|
System.getProperty("line.separator");
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
NodeCLI cli = new NodeCLI();
|
NodeCLI cli = new NodeCLI();
|
||||||
cli.setSysOutPrintStream(System.out);
|
cli.setSysOutPrintStream(System.out);
|
||||||
|
@ -100,48 +104,51 @@ public class NodeCLI extends YarnCLI {
|
||||||
* @param nodeIdStr
|
* @param nodeIdStr
|
||||||
* @throws YarnRemoteException
|
* @throws YarnRemoteException
|
||||||
*/
|
*/
|
||||||
private void printNodeStatus(String nodeIdStr) throws YarnRemoteException {
|
private void printNodeStatus(String nodeIdStr) throws YarnRemoteException,
|
||||||
|
IOException {
|
||||||
NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr);
|
NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr);
|
||||||
List<NodeReport> nodesReport = client.getNodeReports();
|
List<NodeReport> nodesReport = client.getNodeReports();
|
||||||
StringBuffer nodeReportStr = new StringBuffer();
|
// Use PrintWriter.println, which uses correct platform line ending.
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
PrintWriter nodeReportStr = new PrintWriter(baos);
|
||||||
NodeReport nodeReport = null;
|
NodeReport nodeReport = null;
|
||||||
for (NodeReport report : nodesReport) {
|
for (NodeReport report : nodesReport) {
|
||||||
if (!report.getNodeId().equals(nodeId)) {
|
if (!report.getNodeId().equals(nodeId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nodeReport = report;
|
nodeReport = report;
|
||||||
nodeReportStr.append("Node Report : ");
|
nodeReportStr.println("Node Report : ");
|
||||||
nodeReportStr.append("\n\tNode-Id : ");
|
nodeReportStr.print("\tNode-Id : ");
|
||||||
nodeReportStr.append(nodeReport.getNodeId());
|
nodeReportStr.println(nodeReport.getNodeId());
|
||||||
nodeReportStr.append("\n\tRack : ");
|
nodeReportStr.print("\tRack : ");
|
||||||
nodeReportStr.append(nodeReport.getRackName());
|
nodeReportStr.println(nodeReport.getRackName());
|
||||||
nodeReportStr.append("\n\tNode-State : ");
|
nodeReportStr.print("\tNode-State : ");
|
||||||
nodeReportStr.append(nodeReport.getNodeState());
|
nodeReportStr.println(nodeReport.getNodeState());
|
||||||
nodeReportStr.append("\n\tNode-Http-Address : ");
|
nodeReportStr.print("\tNode-Http-Address : ");
|
||||||
nodeReportStr.append(nodeReport.getHttpAddress());
|
nodeReportStr.println(nodeReport.getHttpAddress());
|
||||||
nodeReportStr.append("\n\tHealth-Status(isNodeHealthy) : ");
|
nodeReportStr.print("\tHealth-Status(isNodeHealthy) : ");
|
||||||
nodeReportStr.append(nodeReport.getNodeHealthStatus()
|
nodeReportStr.println(nodeReport.getNodeHealthStatus()
|
||||||
.getIsNodeHealthy());
|
.getIsNodeHealthy());
|
||||||
nodeReportStr.append("\n\tLast-Last-Health-Update : ");
|
nodeReportStr.print("\tLast-Last-Health-Update : ");
|
||||||
nodeReportStr.append(nodeReport.getNodeHealthStatus()
|
nodeReportStr.println(nodeReport.getNodeHealthStatus()
|
||||||
.getLastHealthReportTime());
|
.getLastHealthReportTime());
|
||||||
nodeReportStr.append("\n\tHealth-Report : ");
|
nodeReportStr.print("\tHealth-Report : ");
|
||||||
nodeReportStr
|
nodeReportStr
|
||||||
.append(nodeReport.getNodeHealthStatus().getHealthReport());
|
.println(nodeReport.getNodeHealthStatus().getHealthReport());
|
||||||
nodeReportStr.append("\n\tContainers : ");
|
nodeReportStr.print("\tContainers : ");
|
||||||
nodeReportStr.append(nodeReport.getNumContainers());
|
nodeReportStr.println(nodeReport.getNumContainers());
|
||||||
nodeReportStr.append("\n\tMemory-Used : ");
|
nodeReportStr.print("\tMemory-Used : ");
|
||||||
nodeReportStr.append((nodeReport.getUsed() == null) ? "0M"
|
nodeReportStr.println((nodeReport.getUsed() == null) ? "0M"
|
||||||
: (nodeReport.getUsed().getMemory() + "M"));
|
: (nodeReport.getUsed().getMemory() + "M"));
|
||||||
nodeReportStr.append("\n\tMemory-Capacity : ");
|
nodeReportStr.print("\tMemory-Capacity : ");
|
||||||
nodeReportStr.append(nodeReport.getCapability().getMemory());
|
nodeReportStr.println(nodeReport.getCapability().getMemory());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeReport == null) {
|
if (nodeReport == null) {
|
||||||
nodeReportStr.append("Could not find the node report for node id : "
|
nodeReportStr.print("Could not find the node report for node id : "
|
||||||
+ nodeIdStr);
|
+ nodeIdStr);
|
||||||
}
|
}
|
||||||
|
nodeReportStr.close();
|
||||||
sysout.println(nodeReportStr.toString());
|
sysout.println(baos.toString("UTF-8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -79,12 +80,21 @@ public class TestYarnCLI {
|
||||||
int result = cli.run(new String[] { "-status", applicationId.toString() });
|
int result = cli.run(new String[] { "-status", applicationId.toString() });
|
||||||
assertEquals(0, result);
|
assertEquals(0, result);
|
||||||
verify(client).getApplicationReport(applicationId);
|
verify(client).getApplicationReport(applicationId);
|
||||||
String appReportStr = "Application Report : \n\t"
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
+ "Application-Id : application_1234_0005\n\t"
|
PrintWriter pw = new PrintWriter(baos);
|
||||||
+ "Application-Name : appname\n\tUser : user\n\t"
|
pw.println("Application Report : ");
|
||||||
+ "Queue : queue\n\tStart-Time : 0\n\tFinish-Time : 0\n\t"
|
pw.println("\tApplication-Id : application_1234_0005");
|
||||||
+ "State : FINISHED\n\tFinal-State : SUCCEEDED\n\t"
|
pw.println("\tApplication-Name : appname");
|
||||||
+ "Tracking-URL : N/A\n\tDiagnostics : diagnostics\n";
|
pw.println("\tUser : user");
|
||||||
|
pw.println("\tQueue : queue");
|
||||||
|
pw.println("\tStart-Time : 0");
|
||||||
|
pw.println("\tFinish-Time : 0");
|
||||||
|
pw.println("\tState : FINISHED");
|
||||||
|
pw.println("\tFinal-State : SUCCEEDED");
|
||||||
|
pw.println("\tTracking-URL : N/A");
|
||||||
|
pw.println("\tDiagnostics : diagnostics");
|
||||||
|
pw.close();
|
||||||
|
String appReportStr = baos.toString("UTF-8");
|
||||||
Assert.assertEquals(appReportStr, sysOutStream.toString());
|
Assert.assertEquals(appReportStr, sysOutStream.toString());
|
||||||
verify(sysOut, times(1)).println(isA(String.class));
|
verify(sysOut, times(1)).println(isA(String.class));
|
||||||
}
|
}
|
||||||
|
@ -105,16 +115,18 @@ public class TestYarnCLI {
|
||||||
assertEquals(0, result);
|
assertEquals(0, result);
|
||||||
verify(client).getApplicationList();
|
verify(client).getApplicationList();
|
||||||
|
|
||||||
StringBuffer appsReportStrBuf = new StringBuffer();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
appsReportStrBuf.append("Total Applications:1\n");
|
PrintWriter pw = new PrintWriter(baos);
|
||||||
appsReportStrBuf
|
pw.println("Total Applications:1");
|
||||||
.append(" Application-Id\t Application-Name"
|
pw.print(" Application-Id\t Application-Name");
|
||||||
+ "\t User\t Queue\t State\t "
|
pw.print("\t User\t Queue\t State\t ");
|
||||||
+ "Final-State\t Tracking-URL\n");
|
pw.println("Final-State\t Tracking-URL");
|
||||||
appsReportStrBuf.append(" application_1234_0005\t "
|
pw.print(" application_1234_0005\t ");
|
||||||
+ "appname\t user\t queue\t FINISHED\t "
|
pw.print("appname\t user\t queue\t FINISHED\t ");
|
||||||
+ "SUCCEEDED\t N/A\n");
|
pw.println("SUCCEEDED\t N/A");
|
||||||
Assert.assertEquals(appsReportStrBuf.toString(), sysOutStream.toString());
|
pw.close();
|
||||||
|
String appsReportStr = baos.toString("UTF-8");
|
||||||
|
Assert.assertEquals(appsReportStr, sysOutStream.toString());
|
||||||
verify(sysOut, times(1)).write(any(byte[].class), anyInt(), anyInt());
|
verify(sysOut, times(1)).write(any(byte[].class), anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,18 +149,20 @@ public class TestYarnCLI {
|
||||||
int result = cli.run(new String[] { "-list" });
|
int result = cli.run(new String[] { "-list" });
|
||||||
assertEquals(0, result);
|
assertEquals(0, result);
|
||||||
verify(client).getNodeReports();
|
verify(client).getNodeReports();
|
||||||
StringBuffer nodesReportStr = new StringBuffer();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
nodesReportStr.append("Total Nodes:3");
|
PrintWriter pw = new PrintWriter(baos);
|
||||||
nodesReportStr
|
pw.println("Total Nodes:3");
|
||||||
.append("\n Node-Id\tNode-State\tNode-Http-Address\t"
|
pw.print(" Node-Id\tNode-State\tNode-Http-Address\t");
|
||||||
+ "Health-Status(isNodeHealthy)\tRunning-Containers");
|
pw.println("Health-Status(isNodeHealthy)\tRunning-Containers");
|
||||||
nodesReportStr.append("\n host0:0\t RUNNING\t host1:8888"
|
pw.print(" host0:0\t RUNNING\t host1:8888");
|
||||||
+ "\t false\t 0");
|
pw.println("\t false\t 0");
|
||||||
nodesReportStr.append("\n host1:0\t RUNNING\t host1:8888"
|
pw.print(" host1:0\t RUNNING\t host1:8888");
|
||||||
+ "\t false\t 0");
|
pw.println("\t false\t 0");
|
||||||
nodesReportStr.append("\n host2:0\t RUNNING\t host1:8888"
|
pw.print(" host2:0\t RUNNING\t host1:8888");
|
||||||
+ "\t false\t 0\n");
|
pw.println("\t false\t 0");
|
||||||
Assert.assertEquals(nodesReportStr.toString(), sysOutStream.toString());
|
pw.close();
|
||||||
|
String nodesReportStr = baos.toString("UTF-8");
|
||||||
|
Assert.assertEquals(nodesReportStr, sysOutStream.toString());
|
||||||
verify(sysOut, times(1)).write(any(byte[].class), anyInt(), anyInt());
|
verify(sysOut, times(1)).write(any(byte[].class), anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,11 +177,21 @@ public class TestYarnCLI {
|
||||||
int result = cli.run(new String[] { "-status", nodeId.toString() });
|
int result = cli.run(new String[] { "-status", nodeId.toString() });
|
||||||
assertEquals(0, result);
|
assertEquals(0, result);
|
||||||
verify(client).getNodeReports();
|
verify(client).getNodeReports();
|
||||||
String nodeStatusStr = "Node Report : \n\tNode-Id : host0:0\n\t"
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
+ "Rack : rack1\n\tNode-State : RUNNING\n\t"
|
PrintWriter pw = new PrintWriter(baos);
|
||||||
+ "Node-Http-Address : host1:8888\n\tHealth-Status(isNodeHealthy) "
|
pw.println("Node Report : ");
|
||||||
+ ": false\n\tLast-Last-Health-Update : 0\n\tHealth-Report : null"
|
pw.println("\tNode-Id : host0:0");
|
||||||
+ "\n\tContainers : 0\n\tMemory-Used : 0M\n\tMemory-Capacity : 0";
|
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-Last-Health-Update : 0");
|
||||||
|
pw.println("\tHealth-Report : null");
|
||||||
|
pw.println("\tContainers : 0");
|
||||||
|
pw.println("\tMemory-Used : 0M");
|
||||||
|
pw.println("\tMemory-Capacity : 0");
|
||||||
|
pw.close();
|
||||||
|
String nodeStatusStr = baos.toString("UTF-8");
|
||||||
verify(sysOut, times(1)).println(isA(String.class));
|
verify(sysOut, times(1)).println(isA(String.class));
|
||||||
verify(sysOut).println(nodeStatusStr);
|
verify(sysOut).println(nodeStatusStr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue