Addendum fix for: YARN-7269. Tracking URL in the app state does not get redirected to ApplicationMaster for Running applications. (Wangda Tan)

Change-Id: If1fe4a62e07b25e6f1b8ba803495da87e2cb2df6
This commit is contained in:
Wangda Tan 2017-10-14 10:41:58 -07:00
parent 133d7ca76e
commit 87ea1dff9c
2 changed files with 14 additions and 10 deletions

View File

@ -62,15 +62,19 @@ public void initFilter(FilterContainer container, Configuration conf) {
container.addFilter(FILTER_NAME, FILTER_CLASS, params);
// Handle RM HA urls
List<String> urls = new ArrayList<>();
// Include yarn-site.xml in the classpath
YarnConfiguration yarnConf = new YarnConfiguration(conf);
for (String rmId : getRmIds(yarnConf)) {
String url = getUrlByRmId(yarnConf, rmId);
urls.add(url);
Collection<String> rmIds = getRmIds(yarnConf);
if (rmIds != null) {
List<String> urls = new ArrayList<>();
for (String rmId : rmIds) {
String url = getUrlByRmId(yarnConf, rmId);
urls.add(url);
}
if (!urls.isEmpty()) {
params.put(RM_HA_URLS, StringUtils.join(",", urls));
}
}
params.put(RM_HA_URLS, StringUtils.join(",", urls));
}
private Collection<String> getRmIds(Configuration conf) {

View File

@ -56,11 +56,11 @@ public void testInitFilter() {
AmFilterInitializer afi = new MockAmFilterInitializer();
assertNull(con.givenParameters);
afi.initFilter(con, conf);
assertEquals(3, con.givenParameters.size());
assertEquals(2, con.givenParameters.size());
assertEquals("host1", con.givenParameters.get(AmIpFilter.PROXY_HOSTS));
assertEquals("http://host1:1000/foo",
con.givenParameters.get(AmIpFilter.PROXY_URI_BASES));
assertEquals("", con.givenParameters.get(AmFilterInitializer.RM_HA_URLS));
assertEquals(null, con.givenParameters.get(AmFilterInitializer.RM_HA_URLS));
// Check a single RM_WEBAPP_ADDRESS
con = new MockFilterContainer();
@ -69,11 +69,11 @@ public void testInitFilter() {
afi = new MockAmFilterInitializer();
assertNull(con.givenParameters);
afi.initFilter(con, conf);
assertEquals(3, con.givenParameters.size());
assertEquals(2, con.givenParameters.size());
assertEquals("host2", con.givenParameters.get(AmIpFilter.PROXY_HOSTS));
assertEquals("http://host2:2000/foo",
con.givenParameters.get(AmIpFilter.PROXY_URI_BASES));
assertEquals("", con.givenParameters.get(AmFilterInitializer.RM_HA_URLS));
assertEquals(null, con.givenParameters.get(AmFilterInitializer.RM_HA_URLS));
// Check multiple RM_WEBAPP_ADDRESSes (RM HA)
con = new MockFilterContainer();