This is an automated email from the ASF dual-hosted git repository.
brahma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3a9ccf7 YARN-10141.Interceptor in FederationInterceptorREST doesnt
update on RM switchover. Contributed by D M Murali Krishna Reddy.
3a9ccf7 is described below
commit 3a9ccf7f6d91f12ba6db33142cc033e4957e994f
Author: Brahma Reddy Battula <[email protected]>
AuthorDate: Wed Feb 26 23:24:00 2020 +0530
YARN-10141.Interceptor in FederationInterceptorREST doesnt update on RM
switchover. Contributed by D M Murali Krishna Reddy.
---
.../webapp/DefaultRequestInterceptorREST.java | 4 +++
.../router/webapp/FederationInterceptorREST.java | 6 +++-
.../webapp/TestFederationInterceptorREST.java | 39 ++++++++++++++++++++++
.../webapp/TestableFederationInterceptorREST.java | 2 +-
4 files changed, 49 insertions(+), 2 deletions(-)
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/DefaultRequestInterceptorREST.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/DefaultRequestInterceptorREST.java
index 3dc4fdd..c223c08 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/DefaultRequestInterceptorREST.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/DefaultRequestInterceptorREST.java
@@ -81,6 +81,10 @@ public class DefaultRequestInterceptorREST
this.webAppAddress = webAppAddress;
}
+ protected String getWebAppAddress() {
+ return this.webAppAddress;
+ }
+
protected void setSubClusterId(SubClusterId scId) {
this.subClusterId = scId;
}
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java
index a1b004c..b14da6c 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java
@@ -97,6 +97,7 @@ import
org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
import org.apache.hadoop.yarn.util.Clock;
import org.apache.hadoop.yarn.util.MonotonicClock;
import org.apache.hadoop.yarn.webapp.NotFoundException;
+import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -237,7 +238,10 @@ public class FederationInterceptorREST extends
AbstractRESTRequestInterceptor {
SubClusterId subClusterId, String webAppAddress) {
DefaultRequestInterceptorREST interceptor =
getInterceptorForSubCluster(subClusterId);
- if (interceptor == null) {
+ String webAppAddresswithScheme = WebAppUtils.getHttpSchemePrefix(
+ this.getConf()) + webAppAddress;
+ if (interceptor == null || !webAppAddresswithScheme.equals(interceptor.
+ getWebAppAddress())){
interceptor = createInterceptorForSubCluster(subClusterId,
webAppAddress);
}
return interceptor;
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java
index 54474e5..b3a7e90 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java
@@ -32,6 +32,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
import
org.apache.hadoop.yarn.server.federation.policies.manager.UniformBroadcastPolicyManager;
import
org.apache.hadoop.yarn.server.federation.store.impl.MemoryFederationStateStore;
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
+import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
+import
org.apache.hadoop.yarn.server.federation.store.records.SubClusterRegisterRequest;
+import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState;
import
org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
import
org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreTestUtil;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo;
@@ -44,6 +47,7 @@ import
org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo;
import
org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceOptionInfo;
+import org.apache.hadoop.yarn.util.MonotonicClock;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
@@ -521,4 +525,39 @@ public class TestFederationInterceptorREST extends
BaseRouterWebServicesTest {
Assert.assertNull(response);
}
+ /**
+ * This test validates the creation of new interceptor in case of a
+ * RMSwitchover in a subCluster.
+ */
+ @Test
+ public void testRMSwitchoverOfOneSC() throws Exception {
+ SubClusterId subClusterId = SubClusterId.newInstance(Integer.toString(0));
+
+ interceptor.getClusterMetricsInfo();
+ Assert.assertEquals("http://1.2.3.4:4", interceptor
+ .getInterceptorForSubCluster(subClusterId).getWebAppAddress());
+
+ //Register the first subCluster with secondRM simulating RMSwitchover
+ registerSubClusterWithSwitchoverRM(subClusterId);
+
+ interceptor.getClusterMetricsInfo();
+ Assert.assertEquals("http://5.6.7.8:8", interceptor
+ .getInterceptorForSubCluster(subClusterId).getWebAppAddress());
+ }
+
+ private void registerSubClusterWithSwitchoverRM(SubClusterId subClusterId)
+ throws YarnException {
+ String amRMAddress = "5.6.7.8:5";
+ String clientRMAddress = "5.6.7.8:6";
+ String rmAdminAddress = "5.6.7.8:7";
+ String webAppAddress = "5.6.7.8:8";
+
+ SubClusterInfo subClusterInfo = SubClusterInfo.newInstance(subClusterId,
+ amRMAddress, clientRMAddress, rmAdminAddress, webAppAddress,
+ SubClusterState.SC_RUNNING, new MonotonicClock().getTime(),
+ "capability");
+ stateStore.registerSubCluster(
+ SubClusterRegisterRequest.newInstance(subClusterInfo));
+ }
+
}
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestableFederationInterceptorREST.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestableFederationInterceptorREST.java
index ce5bb23..7126ca5 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestableFederationInterceptorREST.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestableFederationInterceptorREST.java
@@ -42,7 +42,7 @@ public class TestableFederationInterceptorREST
protected void registerBadSubCluster(SubClusterId badSC) {
// Adding in the cache the bad SubCluster, in this way we can stop them
- getOrCreateInterceptorForSubCluster(badSC, "test");
+ getOrCreateInterceptorForSubCluster(badSC, "1.2.3.4:4");
badSubCluster.add(badSC);
MockDefaultRequestInterceptorREST interceptor =
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]