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:
parent
8d62d92372
commit
b0180afc9c
|
@ -73,7 +73,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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<String> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue