Skip to content

Commit f42a11f

Browse files
committed
YARN-1898. Made Standby RM links conf, stacks, logLevel, metrics, jmx, logs and static not be redirected to Active RM. Contributed by Xuan Gong.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1583833 13f79535-47bb-0310-9956-ffa450edef68
1 parent b93a505 commit f42a11f

File tree

3 files changed

+40
-3
lines changed
  • hadoop-yarn-project

3 files changed

+40
-3
lines changed

hadoop-yarn-project/CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ Release 2.4.1 - UNRELEASED
7373

7474
OPTIMIZATIONS
7575

76-
BUG FIXES
76+
BUG FIXES
77+
78+
YARN-1898. Made Standby RM links conf, stacks, logLevel, metrics, jmx, logs
79+
and static not be redirected to Active RM. (Xuan Gong via zjshen)
7780

7881
Release 2.4.0 - 2014-04-07
7982

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,33 @@ public void testRMWebAppRedirect() throws YarnException,
270270
String header = getHeader("Refresh", rm2Url);
271271
assertTrue(header.contains("; url=" + rm1Url));
272272

273+
// standby RM links /conf, /stacks, /logLevel, /metrics, /jmx,
274+
// /static, /logs, /cluster/cluster as well as webService
275+
// /ws/v1/cluster/info should not be redirected to active RM
273276
header = getHeader("Refresh", rm2Url + "/cluster/cluster");
274277
assertEquals(null, header);
275278

279+
header = getHeader("Refresh", rm2Url + "/conf");
280+
assertEquals(null, header);
281+
282+
header = getHeader("Refresh", rm2Url + "/stacks");
283+
assertEquals(null, header);
284+
285+
header = getHeader("Refresh", rm2Url + "/logLevel");
286+
assertEquals(null, header);
287+
288+
header = getHeader("Refresh", rm2Url + "/metrics");
289+
assertEquals(null, header);
290+
291+
header = getHeader("Refresh", rm2Url + "/jmx");
292+
assertEquals(null, header);
293+
294+
header = getHeader("Refresh", rm2Url + "/static");
295+
assertEquals(null, header);
296+
297+
header = getHeader("Refresh", rm2Url + "/logs");
298+
assertEquals(null, header);
299+
276300
header = getHeader("Refresh", rm2Url + "/ws/v1/cluster/info");
277301
assertEquals(null, header);
278302

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebAppFilter.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.io.IOException;
2222
import java.io.PrintWriter;
23+
import java.util.Set;
2324

2425
import javax.inject.Inject;
2526
import javax.inject.Singleton;
@@ -30,6 +31,7 @@
3031

3132
import org.apache.hadoop.http.HtmlQuoting;
3233

34+
import com.google.common.collect.Sets;
3335
import com.google.inject.Injector;
3436
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
3537

@@ -42,6 +44,10 @@ public class RMWebAppFilter extends GuiceContainer {
4244
*/
4345
private static final long serialVersionUID = 1L;
4446

47+
// define a set of URIs which do not need to do redirection
48+
private static final Set<String> NON_REDIRECTED_URIS = Sets.newHashSet(
49+
"/conf", "/stacks", "/logLevel", "/metrics", "/jmx", "/logs");
50+
4551
@Inject
4652
public RMWebAppFilter(Injector injector) {
4753
super(injector);
@@ -61,8 +67,7 @@ public void doFilter(HttpServletRequest request,
6167
RMWebApp rmWebApp = injector.getInstance(RMWebApp.class);
6268
rmWebApp.checkIfStandbyRM();
6369
if (rmWebApp.isStandby()
64-
&& !uri.equals("/" + rmWebApp.wsName() + "/v1/cluster/info")
65-
&& !uri.equals("/" + rmWebApp.name() + "/cluster")) {
70+
&& shouldRedirect(rmWebApp, uri)) {
6671
String redirectPath = rmWebApp.getRedirectPath() + uri;
6772

6873
if (redirectPath != null && !redirectPath.isEmpty()) {
@@ -80,4 +85,9 @@ public void doFilter(HttpServletRequest request,
8085

8186
}
8287

88+
private boolean shouldRedirect(RMWebApp rmWebApp, String uri) {
89+
return !uri.equals("/" + rmWebApp.wsName() + "/v1/cluster/info")
90+
&& !uri.equals("/" + rmWebApp.name() + "/cluster")
91+
&& !NON_REDIRECTED_URIS.contains(uri);
92+
}
8393
}

0 commit comments

Comments
 (0)