YARN-6972. Adding RM ClusterId in AppInfo. (#4673)
This commit is contained in:
parent
0fc7dd8228
commit
c5eba323bc
@ -27,6 +27,8 @@
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import org.apache.hadoop.HadoopIllegalArgumentException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
||||
@ -38,6 +40,8 @@
|
||||
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
||||
import org.apache.hadoop.yarn.api.records.SchedulingRequest;
|
||||
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterIdInfo;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
|
||||
@ -69,6 +73,8 @@ public class AppInfo {
|
||||
protected ApplicationId applicationId;
|
||||
@XmlTransient
|
||||
private String schemePrefix;
|
||||
@XmlTransient
|
||||
private SubClusterIdInfo subClusterId;
|
||||
|
||||
// these are ok for any user to see
|
||||
protected String id;
|
||||
@ -82,6 +88,7 @@ public class AppInfo {
|
||||
protected String trackingUrl;
|
||||
protected String diagnostics;
|
||||
protected long clusterId;
|
||||
protected String rmClusterId;
|
||||
protected String applicationType;
|
||||
protected String applicationTags = "";
|
||||
protected int priority;
|
||||
@ -182,6 +189,16 @@ public AppInfo(ResourceManager rm, RMApp app, Boolean hasAccess,
|
||||
this.finalStatus = app.getFinalApplicationStatus();
|
||||
this.clusterId = ResourceManager.getClusterTimeStamp();
|
||||
if (hasAccess) {
|
||||
if (rm != null && rm.getConfig() != null) {
|
||||
try {
|
||||
Configuration yarnConfig = rm.getConfig();
|
||||
subClusterId = new SubClusterIdInfo(YarnConfiguration.getClusterId(yarnConfig));
|
||||
rmClusterId = this.subClusterId.toId().toString();
|
||||
} catch (HadoopIllegalArgumentException e) {
|
||||
subClusterId = null;
|
||||
rmClusterId = null;
|
||||
}
|
||||
}
|
||||
this.startedTime = app.getStartTime();
|
||||
this.launchTime = app.getLaunchTime();
|
||||
this.finishedTime = app.getFinishTime();
|
||||
@ -454,6 +471,14 @@ public long getClusterId() {
|
||||
return this.clusterId;
|
||||
}
|
||||
|
||||
public SubClusterIdInfo getSubClusterIdInfo() {
|
||||
return this.subClusterId;
|
||||
}
|
||||
|
||||
public String getRmClusterId() {
|
||||
return this.rmClusterId;
|
||||
}
|
||||
|
||||
public String getApplicationType() {
|
||||
return this.applicationType;
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ protected void configureServlets() {
|
||||
YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS);
|
||||
conf.setClass(YarnConfiguration.RM_SCHEDULER, scheduler,
|
||||
ResourceScheduler.class);
|
||||
conf.set(YarnConfiguration.RM_CLUSTER_ID, "subCluster1");
|
||||
rm = new MockRM(conf);
|
||||
bind(ResourceManager.class).toInstance(rm);
|
||||
serve("/*").with(GuiceContainer.class);
|
||||
@ -1805,7 +1806,7 @@ public void verifyAppsXML(NodeList nodes, RMApp app, boolean hasResourceReq)
|
||||
public void verifyAppInfo(JSONObject info, RMApp app, boolean hasResourceReqs)
|
||||
throws JSONException, Exception {
|
||||
|
||||
int expectedNumberOfElements = 40 + (hasResourceReqs ? 2 : 0);
|
||||
int expectedNumberOfElements = 41 + (hasResourceReqs ? 2 : 0);
|
||||
String appNodeLabelExpression = null;
|
||||
String amNodeLabelExpression = null;
|
||||
if (app.getApplicationSubmissionContext()
|
||||
@ -1825,6 +1826,7 @@ public void verifyAppInfo(JSONObject info, RMApp app, boolean hasResourceReqs)
|
||||
}
|
||||
assertEquals("incorrect number of elements", expectedNumberOfElements,
|
||||
info.length());
|
||||
assertEquals("rmClusterId is incorrect", "subCluster1", info.getString("rmClusterId"));
|
||||
verifyAppInfoGeneric(app, info.getString("id"), info.getString("user"),
|
||||
info.getString("name"), info.getString("applicationType"),
|
||||
info.getString("queue"), info.getInt("priority"),
|
||||
|
Loading…
Reference in New Issue
Block a user