diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index ecb44fd82a6..c1078441e31 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -58,7 +58,10 @@ Release 2.4.1 - UNRELEASED OPTIMIZATIONS - BUG FIXES + BUG FIXES + + YARN-1898. Made Standby RM links conf, stacks, logLevel, metrics, jmx, logs + and static not be redirected to Active RM. (Xuan Gong via zjshen) Release 2.4.0 - 2014-04-07 diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java index 40350bc42bd..1ee54e898a4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java @@ -270,9 +270,33 @@ public class TestRMFailover extends ClientBaseWithFixes { String header = getHeader("Refresh", rm2Url); assertTrue(header.contains("; url=" + rm1Url)); + // standby RM links /conf, /stacks, /logLevel, /metrics, /jmx, + // /static, /logs, /cluster/cluster as well as webService + // /ws/v1/cluster/info should not be redirected to active RM header = getHeader("Refresh", rm2Url + "/cluster/cluster"); assertEquals(null, header); + header = getHeader("Refresh", rm2Url + "/conf"); + assertEquals(null, header); + + header = getHeader("Refresh", rm2Url + "/stacks"); + assertEquals(null, header); + + header = getHeader("Refresh", rm2Url + "/logLevel"); + assertEquals(null, header); + + header = getHeader("Refresh", rm2Url + "/metrics"); + assertEquals(null, header); + + header = getHeader("Refresh", rm2Url + "/jmx"); + assertEquals(null, header); + + header = getHeader("Refresh", rm2Url + "/static"); + assertEquals(null, header); + + header = getHeader("Refresh", rm2Url + "/logs"); + assertEquals(null, header); + header = getHeader("Refresh", rm2Url + "/ws/v1/cluster/info"); assertEquals(null, header); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebAppFilter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebAppFilter.java index fd472dd3906..653432b8a97 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebAppFilter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebAppFilter.java @@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; import java.io.IOException; import java.io.PrintWriter; +import java.util.Set; import javax.inject.Inject; import javax.inject.Singleton; @@ -30,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.hadoop.http.HtmlQuoting; +import com.google.common.collect.Sets; import com.google.inject.Injector; import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; @@ -42,6 +44,10 @@ public class RMWebAppFilter extends GuiceContainer { */ private static final long serialVersionUID = 1L; + // define a set of URIs which do not need to do redirection + private static final Set NON_REDIRECTED_URIS = Sets.newHashSet( + "/conf", "/stacks", "/logLevel", "/metrics", "/jmx", "/logs"); + @Inject public RMWebAppFilter(Injector injector) { super(injector); @@ -61,8 +67,7 @@ public class RMWebAppFilter extends GuiceContainer { RMWebApp rmWebApp = injector.getInstance(RMWebApp.class); rmWebApp.checkIfStandbyRM(); if (rmWebApp.isStandby() - && !uri.equals("/" + rmWebApp.wsName() + "/v1/cluster/info") - && !uri.equals("/" + rmWebApp.name() + "/cluster")) { + && shouldRedirect(rmWebApp, uri)) { String redirectPath = rmWebApp.getRedirectPath() + uri; if (redirectPath != null && !redirectPath.isEmpty()) { @@ -80,4 +85,9 @@ public class RMWebAppFilter extends GuiceContainer { } + private boolean shouldRedirect(RMWebApp rmWebApp, String uri) { + return !uri.equals("/" + rmWebApp.wsName() + "/v1/cluster/info") + && !uri.equals("/" + rmWebApp.name() + "/cluster") + && !NON_REDIRECTED_URIS.contains(uri); + } }