YARN-4498. Application level node labels stats to be available in REST (addendum patch). Contributed by Bibin A Chundatt.

(cherry picked from commit 8a2998c08c)
This commit is contained in:
Naganarasimha 2016-11-10 05:21:07 +05:30
parent 1d75da8e26
commit 108f09a763
2 changed files with 10 additions and 4 deletions

View File

@ -106,7 +106,7 @@ public class AppInfo {
protected String appNodeLabelExpression;
protected String amNodeLabelExpression;
protected ResourcesInfo resourceInfo;
protected ResourcesInfo resourceInfo = null;
public AppInfo() {
} // JAXB needs this
@ -219,7 +219,7 @@ public class AppInfo {
.getApplicationAttempt(attempt.getAppAttemptId());
resourceInfo = null != ficaAppAttempt
? new ResourcesInfo(ficaAppAttempt.getSchedulingResourceUsage())
: new ResourcesInfo();
: null;
}
}
}

View File

@ -19,6 +19,8 @@
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.HashSet;
@ -157,8 +159,12 @@ public class TestRMWebServiceAppsNodelabel extends JerseyTestBase {
JSONObject json = response.getEntity(JSONObject.class);
JSONObject apps = json.getJSONObject("apps");
assertEquals("incorrect number of elements", 1, apps.length());
Object object = apps.getJSONArray("app").getJSONObject(0).get("resourceInfo");
Assert.assertTrue("For finshed app null expected", object.equals(null));
try {
apps.getJSONArray("app").getJSONObject(0).getJSONObject("resourceInfo");
fail("resourceInfo object shouldnt be available for finished apps");
} catch (Exception e) {
assertTrue("resourceInfo shouldn't be available for finished apps", true);
}
rm.stop();
}