Skip to content

Commit

Permalink
Using isUnmanagedApp to determine managed/unmanaged app instead of ge…
Browse files Browse the repository at this point in the history
…tHost
  • Loading branch information
akshatb1 committed Jul 9, 2021
1 parent 5992557 commit 67155ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static GetApplicationsResponse mergeApplications(
for (ApplicationReport appReport : appResponse.getApplicationList()){
ApplicationId appId = appReport.getApplicationId();
// Check if this ApplicationReport is an AM
if (appReport.getHost() != null) {
if (!appReport.isUnmanagedApp()) {
// Insert in the list of AM
federationAM.put(appId, appReport);
// Check if there are any UAM found before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
import org.apache.hadoop.yarn.server.uam.UnmanagedApplicationManager;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -76,10 +77,20 @@ public void testMergeApplications() {
ArrayList<GetApplicationsResponse> responses = new ArrayList<>();
responses.add(getApplicationsResponse(1, false));
responses.add(getApplicationsResponse(2, false));

GetApplicationsResponse result = RouterYarnClientUtils.
mergeApplications(responses, false);
Assert.assertNotNull(result);
Assert.assertEquals(2, result.getApplicationList().size());

String appName1 = result.getApplicationList().get(0).getName();
String appName2 = result.getApplicationList().get(1).getName();

// Check that no Unmanaged applications are added to the result
Assert.assertEquals(false,
appName1.contains(UnmanagedApplicationManager.APP_NAME));
Assert.assertEquals(false,
appName2.contains(UnmanagedApplicationManager.APP_NAME));
}

/**
Expand Down Expand Up @@ -125,10 +136,11 @@ public void testMergeUnmanagedApplications() {
*/
private GetApplicationsResponse getApplicationsResponse(int value,
boolean uamOnly) {
String host = uamOnly? null: "host";
String appName = uamOnly? UnmanagedApplicationManager.APP_NAME: "appname";
List<ApplicationReport> applications = new ArrayList<>();

//Add managed application to list
// Create first application report. This is a managed app by default.
// If uamOnly is true, this becomes unmanaged application.
ApplicationId appId = ApplicationId.newInstance(1234, value);
Resource resource = Resource.newInstance(1024, 1);
ApplicationResourceUsageReport appResourceUsageReport =
Expand All @@ -139,24 +151,21 @@ private GetApplicationsResponse getApplicationsResponse(int value,

ApplicationReport appReport = ApplicationReport.newInstance(
appId, ApplicationAttemptId.newInstance(appId, 1),
"user", "queue", "appname", host,
"user", "queue", appName, "host",
124, null, YarnApplicationState.RUNNING,
"diagnostics", "url", 0, 0,
0, FinalApplicationStatus.SUCCEEDED,
appResourceUsageReport,
"N/A", 0.53789f, "YARN",
null);
0, FinalApplicationStatus.SUCCEEDED, appResourceUsageReport, "N/A",
0.53789f, "YARN", null, null, uamOnly, null, null, null);

// Add unmanaged application to list
// Create second application report. This is always unmanaged application.
ApplicationId appId2 = ApplicationId.newInstance(1234, value);
ApplicationReport appReport2 = ApplicationReport.newInstance(
appId2, ApplicationAttemptId.newInstance(appId2, 1),
"user", "queue", "appname", null, 124,
null, YarnApplicationState.RUNNING,
appId2, ApplicationAttemptId.newInstance(appId, 1),
"user", "queue", UnmanagedApplicationManager.APP_NAME, "host",
124, null, YarnApplicationState.RUNNING,
"diagnostics", "url", 0, 0,
0, FinalApplicationStatus.SUCCEEDED, appResourceUsageReport,
"N/A", 0.53789f,
"YARN", null);
0, FinalApplicationStatus.SUCCEEDED, appResourceUsageReport, "N/A",
0.53789f, "YARN", null, null, true, null, null, null);

applications.add(appReport);
applications.add(appReport2);
Expand Down

0 comments on commit 67155ef

Please sign in to comment.