Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -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"),
Expand Down