YARN-5612. Return SubClusterId in FederationStateStoreFacade#addApplicationHomeSubCluster for Router Failover. (Giovanni Matteo Fumarola via Subru).
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1f5e494c Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1f5e494c Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1f5e494c Branch: refs/heads/YARN-2915 Commit: 1f5e494c1fa6bfba13e45d6f80c00253957d4c2e Parents: 3941da9 Author: Subru Krishnan <s...@apache.org> Authored: Thu Sep 1 13:55:54 2016 -0700 Committer: Subru Krishnan <su...@apache.org> Committed: Thu Jan 5 19:08:19 2017 -0800 ---------------------------------------------------------------------- .../utils/FederationStateStoreFacade.java | 11 ++++--- .../utils/TestFederationStateStoreFacade.java | 30 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1f5e494c/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java index f1c8218..66a0b60 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java @@ -48,6 +48,7 @@ import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; import org.apache.hadoop.yarn.server.federation.store.FederationStateStore; import org.apache.hadoop.yarn.server.federation.store.records.AddApplicationHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.AddApplicationHomeSubClusterResponse; import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster; import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterRequest; import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterResponse; @@ -298,13 +299,15 @@ public final class FederationStateStoreFacade { * * @param appHomeSubCluster the mapping of the application to it's home * sub-cluster + * @return the stored Subcluster from StateStore * @throws YarnException if the call to the state store is unsuccessful */ - public void addApplicationHomeSubCluster( + public SubClusterId addApplicationHomeSubCluster( ApplicationHomeSubCluster appHomeSubCluster) throws YarnException { - stateStore.addApplicationHomeSubCluster( - AddApplicationHomeSubClusterRequest.newInstance(appHomeSubCluster)); - return; + AddApplicationHomeSubClusterResponse response = + stateStore.addApplicationHomeSubCluster( + AddApplicationHomeSubClusterRequest.newInstance(appHomeSubCluster)); + return response.getHomeSubCluster(); } /** http://git-wip-us.apache.org/repos/asf/hadoop/blob/1f5e494c/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacade.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacade.java index 53f4f84..d46bef0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacade.java @@ -28,6 +28,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.federation.store.FederationStateStore; import org.apache.hadoop.yarn.server.federation.store.impl.MemoryFederationStateStore; +import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster; 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.SubClusterPolicyConfiguration; @@ -145,4 +146,33 @@ public class TestFederationStateStoreFacade { } } + @Test + public void testAddApplicationHomeSubCluster() throws YarnException { + + // Inserting <AppId, Home1> into FederationStateStore + ApplicationId appId = ApplicationId.newInstance(clusterTs, numApps + 1); + SubClusterId subClusterId1 = SubClusterId.newInstance("Home1"); + + ApplicationHomeSubCluster appHomeSubCluster = + ApplicationHomeSubCluster.newInstance(appId, subClusterId1); + + SubClusterId result = + facade.addApplicationHomeSubCluster(appHomeSubCluster); + + Assert.assertEquals(facade.getApplicationHomeSubCluster(appId), result); + Assert.assertEquals(subClusterId1, result); + + // Inserting <AppId, Home2> into FederationStateStore. + // The application is already present. + // FederationFacade will return Home1 as SubClusterId. + SubClusterId subClusterId2 = SubClusterId.newInstance("Home2"); + appHomeSubCluster = + ApplicationHomeSubCluster.newInstance(appId, subClusterId2); + + result = facade.addApplicationHomeSubCluster(appHomeSubCluster); + + Assert.assertEquals(facade.getApplicationHomeSubCluster(appId), result); + Assert.assertEquals(subClusterId1, result); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org