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:
parent
133d7ca76e
commit
87ea1dff9c
@ -62,15 +62,19 @@ public void initFilter(FilterContainer container, Configuration conf) {
|
|||||||
container.addFilter(FILTER_NAME, FILTER_CLASS, params);
|
container.addFilter(FILTER_NAME, FILTER_CLASS, params);
|
||||||
|
|
||||||
// Handle RM HA urls
|
// Handle RM HA urls
|
||||||
List<String> urls = new ArrayList<>();
|
|
||||||
|
|
||||||
// Include yarn-site.xml in the classpath
|
// Include yarn-site.xml in the classpath
|
||||||
YarnConfiguration yarnConf = new YarnConfiguration(conf);
|
YarnConfiguration yarnConf = new YarnConfiguration(conf);
|
||||||
for (String rmId : getRmIds(yarnConf)) {
|
Collection<String> rmIds = getRmIds(yarnConf);
|
||||||
String url = getUrlByRmId(yarnConf, rmId);
|
if (rmIds != null) {
|
||||||
urls.add(url);
|
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) {
|
private Collection<String> getRmIds(Configuration conf) {
|
||||||
|
@ -56,11 +56,11 @@ public void testInitFilter() {
|
|||||||
AmFilterInitializer afi = new MockAmFilterInitializer();
|
AmFilterInitializer afi = new MockAmFilterInitializer();
|
||||||
assertNull(con.givenParameters);
|
assertNull(con.givenParameters);
|
||||||
afi.initFilter(con, conf);
|
afi.initFilter(con, conf);
|
||||||
assertEquals(3, con.givenParameters.size());
|
assertEquals(2, con.givenParameters.size());
|
||||||
assertEquals("host1", con.givenParameters.get(AmIpFilter.PROXY_HOSTS));
|
assertEquals("host1", con.givenParameters.get(AmIpFilter.PROXY_HOSTS));
|
||||||
assertEquals("http://host1:1000/foo",
|
assertEquals("http://host1:1000/foo",
|
||||||
con.givenParameters.get(AmIpFilter.PROXY_URI_BASES));
|
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
|
// Check a single RM_WEBAPP_ADDRESS
|
||||||
con = new MockFilterContainer();
|
con = new MockFilterContainer();
|
||||||
@ -69,11 +69,11 @@ public void testInitFilter() {
|
|||||||
afi = new MockAmFilterInitializer();
|
afi = new MockAmFilterInitializer();
|
||||||
assertNull(con.givenParameters);
|
assertNull(con.givenParameters);
|
||||||
afi.initFilter(con, conf);
|
afi.initFilter(con, conf);
|
||||||
assertEquals(3, con.givenParameters.size());
|
assertEquals(2, con.givenParameters.size());
|
||||||
assertEquals("host2", con.givenParameters.get(AmIpFilter.PROXY_HOSTS));
|
assertEquals("host2", con.givenParameters.get(AmIpFilter.PROXY_HOSTS));
|
||||||
assertEquals("http://host2:2000/foo",
|
assertEquals("http://host2:2000/foo",
|
||||||
con.givenParameters.get(AmIpFilter.PROXY_URI_BASES));
|
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)
|
// Check multiple RM_WEBAPP_ADDRESSes (RM HA)
|
||||||
con = new MockFilterContainer();
|
con = new MockFilterContainer();
|
||||||
|
Loading…
Reference in New Issue
Block a user