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
This commit is contained in:
Zhijie Shen 2014-04-02 00:01:50 +00:00
parent 8d62d92372
commit b0180afc9c
3 changed files with 40 additions and 3 deletions

View File

@ -73,7 +73,10 @@ Release 2.4.1 - UNRELEASED
OPTIMIZATIONS 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 Release 2.4.0 - 2014-04-07

View File

@ -270,9 +270,33 @@ public class TestRMFailover extends ClientBaseWithFixes {
String header = getHeader("Refresh", rm2Url); String header = getHeader("Refresh", rm2Url);
assertTrue(header.contains("; url=" + rm1Url)); 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"); header = getHeader("Refresh", rm2Url + "/cluster/cluster");
assertEquals(null, header); 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"); header = getHeader("Refresh", rm2Url + "/ws/v1/cluster/info");
assertEquals(null, header); assertEquals(null, header);

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -30,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.hadoop.http.HtmlQuoting; import org.apache.hadoop.http.HtmlQuoting;
import com.google.common.collect.Sets;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
@ -42,6 +44,10 @@ public class RMWebAppFilter extends GuiceContainer {
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// define a set of URIs which do not need to do redirection
private static final Set<String> NON_REDIRECTED_URIS = Sets.newHashSet(
"/conf", "/stacks", "/logLevel", "/metrics", "/jmx", "/logs");
@Inject @Inject
public RMWebAppFilter(Injector injector) { public RMWebAppFilter(Injector injector) {
super(injector); super(injector);
@ -61,8 +67,7 @@ public class RMWebAppFilter extends GuiceContainer {
RMWebApp rmWebApp = injector.getInstance(RMWebApp.class); RMWebApp rmWebApp = injector.getInstance(RMWebApp.class);
rmWebApp.checkIfStandbyRM(); rmWebApp.checkIfStandbyRM();
if (rmWebApp.isStandby() if (rmWebApp.isStandby()
&& !uri.equals("/" + rmWebApp.wsName() + "/v1/cluster/info") && shouldRedirect(rmWebApp, uri)) {
&& !uri.equals("/" + rmWebApp.name() + "/cluster")) {
String redirectPath = rmWebApp.getRedirectPath() + uri; String redirectPath = rmWebApp.getRedirectPath() + uri;
if (redirectPath != null && !redirectPath.isEmpty()) { 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);
}
} }