YARN-6973. Adding RM Cluster Id in ApplicationReport. Contributed by Bilwa S T.

This commit is contained in:
Inigo Goiri 2020-04-29 11:23:58 -07:00
parent 9ca6298a9a
commit d125d39108
6 changed files with 44 additions and 0 deletions

View File

@ -539,4 +539,17 @@ public abstract class ApplicationReport {
@Unstable
public abstract void setApplicationTimeouts(
Map<ApplicationTimeoutType, ApplicationTimeout> timeouts);
/**
* Get RM ClusterId.
*
* @return RM ClusterId
*/
@Public
@Stable
public abstract String getRMClusterId();
@Public
@Stable
public abstract void setRMClusterId(String rmClusterId);
}

View File

@ -288,6 +288,7 @@ message ApplicationReportProto {
repeated AppTimeoutsMapProto appTimeouts = 26;
optional int64 launchTime = 27;
optional int64 submitTime = 28;
optional string rmClusterId = 29;
}
message AppTimeoutsMapProto {

View File

@ -664,6 +664,11 @@ public class ApplicationCLI extends YarnCLI {
appReportStr.println(
"\tRemainingTime : " + timeout.getRemainingTime() + "seconds");
}
String rmClusterId = appReport.getRMClusterId();
if (rmClusterId != null) {
appReportStr.print("\tRMClusterId : ");
appReportStr.println(rmClusterId);
}
} else {
appReportStr.print("Application with id '" + applicationId
+ "' doesn't exist in RM.");

View File

@ -147,6 +147,7 @@ public class TestYarnCLI {
null, null, false, Priority.newInstance(0), "high-mem", "high-mem");
newApplicationReport.setLogAggregationStatus(LogAggregationStatus.SUCCEEDED);
newApplicationReport.setPriority(Priority.newInstance(0));
newApplicationReport.setRMClusterId("Cluster1");
ApplicationTimeout timeout = ApplicationTimeout
.newInstance(ApplicationTimeoutType.LIFETIME, "UNLIMITED", -1);
newApplicationReport.setApplicationTimeouts(
@ -186,6 +187,7 @@ public class TestYarnCLI {
pw.print("\tTimeoutType : LIFETIME");
pw.print("\tExpiryTime : UNLIMITED");
pw.println("\tRemainingTime : -1seconds");
pw.println("\tRMClusterId : Cluster1");
pw.println();
pw.close();
String appReportStr = baos.toString("UTF-8");

View File

@ -787,4 +787,23 @@ public class ApplicationReportPBImpl extends ApplicationReport {
this.builder.addAllAppTimeouts(values);
}
@Override
public String getRMClusterId() {
ApplicationReportProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasRmClusterId()) {
return null;
}
return p.getRmClusterId();
}
@Override
public void setRMClusterId(String rmClusterId) {
maybeInitBuilder();
if (rmClusterId == null) {
builder.clearRmClusterId();
return;
}
builder.setRmClusterId((rmClusterId));
}
}

View File

@ -61,6 +61,7 @@ import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.client.api.AppAdminClient;
import org.apache.hadoop.yarn.conf.HAUtil;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.Dispatcher;
import org.apache.hadoop.yarn.event.EventHandler;
@ -772,6 +773,9 @@ public class RMAppImpl implements RMApp, Recoverable {
report.setUnmanagedApp(submissionContext.getUnmanagedAM());
report.setAppNodeLabelExpression(getAppNodeLabelExpression());
report.setAmNodeLabelExpression(getAmNodeLabelExpression());
if (HAUtil.isFederationEnabled(conf)) {
report.setRMClusterId(YarnConfiguration.getClusterId(conf));
}
ApplicationTimeout timeout = ApplicationTimeout
.newInstance(ApplicationTimeoutType.LIFETIME, UNLIMITED, UNKNOWN);