YARN-577. Add application-progress also to ApplicationReport. Contributed by Hitesh Shah.

MAPREDUCE-5178. Update MR App to set progress in ApplicationReport after YARN-577. Contributed by Hitesh Shah.
svn merge --ignore-ancestry -c 1475636 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1475637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-04-25 05:45:15 +00:00
parent 74885ea5c0
commit a1fe9a0c9f
11 changed files with 58 additions and 13 deletions

View File

@ -194,6 +194,9 @@ Release 2.0.5-beta - UNRELEASED
MAPREDUCE-5181. RMCommunicator should not use AMToken from the env. MAPREDUCE-5181. RMCommunicator should not use AMToken from the env.
(Vinod Kumar Vavilapalli via sseth) (Vinod Kumar Vavilapalli via sseth)
MAPREDUCE-5178. Update MR App to set progress in ApplicationReport after
YARN-577. (Hitesh Shah via vinodkv)
Release 2.0.4-alpha - UNRELEASED Release 2.0.4-alpha - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -89,7 +89,7 @@ public class NotRunningJob implements MRClientProtocol {
// used for a non running job // used for a non running job
return BuilderUtils.newApplicationReport(unknownAppId, unknownAttemptId, return BuilderUtils.newApplicationReport(unknownAppId, unknownAttemptId,
"N/A", "N/A", "N/A", "N/A", 0, null, YarnApplicationState.NEW, "N/A", "N/A", "N/A", "N/A", "N/A", 0, null, YarnApplicationState.NEW, "N/A",
"N/A", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A"); "N/A", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f);
} }
NotRunningJob(ApplicationReport applicationReport, JobState jobState) { NotRunningJob(ApplicationReport applicationReport, JobState jobState) {

View File

@ -413,7 +413,7 @@ public class TestClientServiceDelegate {
return BuilderUtils.newApplicationReport(appId, attemptId, "user", "queue", return BuilderUtils.newApplicationReport(appId, attemptId, "user", "queue",
"appname", "host", 124, null, YarnApplicationState.FINISHED, "appname", "host", 124, null, YarnApplicationState.FINISHED,
"diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null, "diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null,
"N/A"); "N/A", 0.0f);
} }
private ApplicationReport getRunningApplicationReport(String host, int port) { private ApplicationReport getRunningApplicationReport(String host, int port) {
@ -423,7 +423,7 @@ public class TestClientServiceDelegate {
return BuilderUtils.newApplicationReport(appId, attemptId, "user", "queue", return BuilderUtils.newApplicationReport(appId, attemptId, "user", "queue",
"appname", host, port, null, YarnApplicationState.RUNNING, "appname", host, port, null, YarnApplicationState.RUNNING,
"diagnostics", "url", 0, 0, FinalApplicationStatus.UNDEFINED, null, "diagnostics", "url", 0, 0, FinalApplicationStatus.UNDEFINED, null,
"N/A"); "N/A", 0.0f);
} }
private ResourceMgrDelegate getRMDelegate() throws YarnRemoteException { private ResourceMgrDelegate getRMDelegate() throws YarnRemoteException {

View File

@ -110,6 +110,9 @@ Release 2.0.5-beta - UNRELEASED
YARN-581. Added a test to verify that app delegation tokens are restored YARN-581. Added a test to verify that app delegation tokens are restored
after RM restart. (Jian He via vinodkv) after RM restart. (Jian He via vinodkv)
YARN-577. Add application-progress also to ApplicationReport. (Hitesh Shah
via vinodkv)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -253,4 +253,16 @@ public interface ApplicationReport {
@Private @Private
@Unstable @Unstable
void setApplicationResourceUsageReport(ApplicationResourceUsageReport appResources); void setApplicationResourceUsageReport(ApplicationResourceUsageReport appResources);
/**
* Get the application's progress ( range 0.0 to 1.0 )
* @return application's progress
*/
@Public
@Stable
float getProgress();
@Private
@Unstable
void setProgress(float progress);
} }

View File

@ -213,6 +213,12 @@ implements ApplicationReport {
return convertFromProtoFormat(p.getFinalApplicationStatus()); return convertFromProtoFormat(p.getFinalApplicationStatus());
} }
@Override
public float getProgress() {
ApplicationReportProtoOrBuilder p = viaProto ? proto : builder;
return p.getProgress();
}
@Override @Override
public void setApplicationId(ApplicationId applicationId) { public void setApplicationId(ApplicationId applicationId) {
maybeInitBuilder(); maybeInitBuilder();
@ -345,6 +351,12 @@ implements ApplicationReport {
builder.setFinalApplicationStatus(convertToProtoFormat(finishState)); builder.setFinalApplicationStatus(convertToProtoFormat(finishState));
} }
@Override
public void setProgress(float progress) {
maybeInitBuilder();
builder.setProgress(progress);
}
@Override @Override
public ApplicationReportProto getProto() { public ApplicationReportProto getProto() {
mergeLocalToProto(); mergeLocalToProto();

View File

@ -162,6 +162,7 @@ message ApplicationReportProto {
optional ApplicationResourceUsageReportProto app_resource_Usage = 16; optional ApplicationResourceUsageReportProto app_resource_Usage = 16;
optional string originalTrackingUrl = 17; optional string originalTrackingUrl = 17;
optional ApplicationAttemptIdProto currentApplicationAttemptId = 18; optional ApplicationAttemptIdProto currentApplicationAttemptId = 18;
optional float progress = 19;
} }
enum NodeStateProto { enum NodeStateProto {

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.client.cli;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.List; import java.util.List;
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLine;
@ -34,7 +35,7 @@ import org.apache.hadoop.yarn.util.ConverterUtils;
public class ApplicationCLI extends YarnCLI { public class ApplicationCLI extends YarnCLI {
private static final String APPLICATIONS_PATTERN = private static final String APPLICATIONS_PATTERN =
"%30s\t%20s\t%10s\t%10s\t%18s\t%18s\t%35s" + "%30s\t%20s\t%10s\t%10s\t%18s\t%18s\t%15s\t%35s" +
System.getProperty("line.separator"); System.getProperty("line.separator");
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -98,12 +99,15 @@ public class ApplicationCLI extends YarnCLI {
writer.println("Total Applications:" + appsReport.size()); writer.println("Total Applications:" + appsReport.size());
writer.printf(APPLICATIONS_PATTERN, "Application-Id", writer.printf(APPLICATIONS_PATTERN, "Application-Id",
"Application-Name", "User", "Queue", "State", "Final-State", "Application-Name", "User", "Queue", "State", "Final-State",
"Tracking-URL"); "Progress", "Tracking-URL");
for (ApplicationReport appReport : appsReport) { for (ApplicationReport appReport : appsReport) {
DecimalFormat formatter = new DecimalFormat("###.##%");
String progress = formatter.format(appReport.getProgress());
writer.printf(APPLICATIONS_PATTERN, appReport.getApplicationId(), writer.printf(APPLICATIONS_PATTERN, appReport.getApplicationId(),
appReport.getName(), appReport.getUser(), appReport.getQueue(), appReport.getName(), appReport.getUser(), appReport.getQueue(),
appReport.getYarnApplicationState(), appReport appReport.getYarnApplicationState(), appReport
.getFinalApplicationStatus(), appReport.getOriginalTrackingUrl()); .getFinalApplicationStatus(),
progress, appReport.getOriginalTrackingUrl());
} }
writer.flush(); writer.flush();
} }
@ -147,6 +151,10 @@ public class ApplicationCLI extends YarnCLI {
appReportStr.println(appReport.getStartTime()); appReportStr.println(appReport.getStartTime());
appReportStr.print("\tFinish-Time : "); appReportStr.print("\tFinish-Time : ");
appReportStr.println(appReport.getFinishTime()); appReportStr.println(appReport.getFinishTime());
appReportStr.print("\tProgress : ");
DecimalFormat formatter = new DecimalFormat("###.##%");
String progress = formatter.format(appReport.getProgress());
appReportStr.println(progress);
appReportStr.print("\tState : "); appReportStr.print("\tState : ");
appReportStr.println(appReport.getYarnApplicationState()); appReportStr.println(appReport.getYarnApplicationState());
appReportStr.print("\tFinal-State : "); appReportStr.print("\tFinal-State : ");

View File

@ -76,7 +76,7 @@ public class TestYarnCLI {
applicationId, BuilderUtils.newApplicationAttemptId(applicationId, 1), applicationId, BuilderUtils.newApplicationAttemptId(applicationId, 1),
"user", "queue", "appname", "host", 124, null, "user", "queue", "appname", "host", 124, null,
YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0, YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
FinalApplicationStatus.SUCCEEDED, null, "N/A"); FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f);
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn( when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
newApplicationReport); newApplicationReport);
int result = cli.run(new String[] { "-status", applicationId.toString() }); int result = cli.run(new String[] { "-status", applicationId.toString() });
@ -91,6 +91,7 @@ public class TestYarnCLI {
pw.println("\tQueue : queue"); pw.println("\tQueue : queue");
pw.println("\tStart-Time : 0"); pw.println("\tStart-Time : 0");
pw.println("\tFinish-Time : 0"); pw.println("\tFinish-Time : 0");
pw.println("\tProgress : 53.79%");
pw.println("\tState : FINISHED"); pw.println("\tState : FINISHED");
pw.println("\tFinal-State : SUCCEEDED"); pw.println("\tFinal-State : SUCCEEDED");
pw.println("\tTracking-URL : N/A"); pw.println("\tTracking-URL : N/A");
@ -111,7 +112,7 @@ public class TestYarnCLI {
applicationId, BuilderUtils.newApplicationAttemptId(applicationId, 1), applicationId, BuilderUtils.newApplicationAttemptId(applicationId, 1),
"user", "queue", "appname", "host", 124, null, "user", "queue", "appname", "host", 124, null,
YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0, YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
FinalApplicationStatus.SUCCEEDED, null, "N/A"); FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f);
List<ApplicationReport> applicationReports = new ArrayList<ApplicationReport>(); List<ApplicationReport> applicationReports = new ArrayList<ApplicationReport>();
applicationReports.add(newApplicationReport); applicationReports.add(newApplicationReport);
when(client.getApplicationList()).thenReturn(applicationReports); when(client.getApplicationList()).thenReturn(applicationReports);
@ -124,10 +125,12 @@ public class TestYarnCLI {
pw.println("Total Applications:1"); pw.println("Total Applications:1");
pw.print(" Application-Id\t Application-Name"); pw.print(" Application-Id\t Application-Name");
pw.print("\t User\t Queue\t State\t "); pw.print("\t User\t Queue\t State\t ");
pw.println("Final-State\t Tracking-URL"); pw.print("Final-State\t Progress");
pw.println("\t Tracking-URL");
pw.print(" application_1234_0005\t "); pw.print(" application_1234_0005\t ");
pw.print("appname\t user\t queue\t FINISHED\t "); pw.print("appname\t user\t queue\t FINISHED\t ");
pw.println("SUCCEEDED\t N/A"); pw.print("SUCCEEDED\t 53.79%");
pw.println("\t N/A");
pw.close(); pw.close();
String appsReportStr = baos.toString("UTF-8"); String appsReportStr = baos.toString("UTF-8");
Assert.assertEquals(appsReportStr, sysOutStream.toString()); Assert.assertEquals(appsReportStr, sysOutStream.toString());

View File

@ -333,7 +333,8 @@ public class BuilderUtils {
ClientToken clientToken, YarnApplicationState state, String diagnostics, ClientToken clientToken, YarnApplicationState state, String diagnostics,
String url, long startTime, long finishTime, String url, long startTime, long finishTime,
FinalApplicationStatus finalStatus, FinalApplicationStatus finalStatus,
ApplicationResourceUsageReport appResources, String origTrackingUrl) { ApplicationResourceUsageReport appResources, String origTrackingUrl,
float progress) {
ApplicationReport report = recordFactory ApplicationReport report = recordFactory
.newRecordInstance(ApplicationReport.class); .newRecordInstance(ApplicationReport.class);
report.setApplicationId(applicationId); report.setApplicationId(applicationId);
@ -352,6 +353,7 @@ public class BuilderUtils {
report.setFinalApplicationStatus(finalStatus); report.setFinalApplicationStatus(finalStatus);
report.setApplicationResourceUsageReport(appResources); report.setApplicationResourceUsageReport(appResources);
report.setOriginalTrackingUrl(origTrackingUrl); report.setOriginalTrackingUrl(origTrackingUrl);
report.setProgress(progress);
return report; return report;
} }

View File

@ -437,6 +437,7 @@ public class RMAppImpl implements RMApp, Recoverable {
DUMMY_APPLICATION_RESOURCE_USAGE_REPORT; DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
FinalApplicationStatus finishState = getFinalApplicationStatus(); FinalApplicationStatus finishState = getFinalApplicationStatus();
String diags = UNAVAILABLE; String diags = UNAVAILABLE;
float progress = 0.0f;
if (allowAccess) { if (allowAccess) {
if (this.currentAttempt != null) { if (this.currentAttempt != null) {
currentApplicationAttemptId = this.currentAttempt.getAppAttemptId(); currentApplicationAttemptId = this.currentAttempt.getAppAttemptId();
@ -446,8 +447,8 @@ public class RMAppImpl implements RMApp, Recoverable {
host = this.currentAttempt.getHost(); host = this.currentAttempt.getHost();
rpcPort = this.currentAttempt.getRpcPort(); rpcPort = this.currentAttempt.getRpcPort();
appUsageReport = currentAttempt.getApplicationResourceUsageReport(); appUsageReport = currentAttempt.getApplicationResourceUsageReport();
progress = currentAttempt.getProgress();
} }
diags = this.diagnostics.toString(); diags = this.diagnostics.toString();
} }
@ -462,7 +463,7 @@ public class RMAppImpl implements RMApp, Recoverable {
this.name, host, rpcPort, clientToken, this.name, host, rpcPort, clientToken,
createApplicationState(this.stateMachine.getCurrentState()), diags, createApplicationState(this.stateMachine.getCurrentState()), diags,
trackingUrl, this.startTime, this.finishTime, finishState, trackingUrl, this.startTime, this.finishTime, finishState,
appUsageReport, origTrackingUrl); appUsageReport, origTrackingUrl, progress);
} finally { } finally {
this.readLock.unlock(); this.readLock.unlock();
} }