diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/SQLFederationStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/SQLFederationStateStore.java index e62dcaf2a7f..273118aebaa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/SQLFederationStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/SQLFederationStateStore.java @@ -564,13 +564,13 @@ public AddApplicationHomeSubClusterResponse addApplicationHomeSubCluster( // Check the ROWCOUNT value, if it is equal to 0 it means the call // did not add a new application into FederationStateStore if (cstmt.getInt(4) == 0) { - String errMsg = "The application " + appId - + " was not insert into the StateStore"; - FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); - } - // Check the ROWCOUNT value, if it is different from 1 it means the call - // had a wrong behavior. Maybe the database is not set correctly. - if (cstmt.getInt(4) != 1) { + LOG.info( + "The application {} was not inserted in the StateStore because it" + + " was already present in SubCluster {}", + appId, subClusterHome); + } else if (cstmt.getInt(4) != 1) { + // Check the ROWCOUNT value, if it is different from 1 it means the + // call had a wrong behavior. Maybe the database is not set correctly. String errMsg = "Wrong behavior during the insertion of SubCluster " + subClusterId; FederationStateStoreUtils.logAndThrowStoreException(LOG, errMsg); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/FederationStateStoreBaseTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/FederationStateStoreBaseTest.java index 15cc0f0a009..b17f8702a94 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/FederationStateStoreBaseTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/FederationStateStoreBaseTest.java @@ -281,6 +281,25 @@ public void testAddApplicationHomeSubClusterAppAlreadyExists() } + @Test + public void testAddApplicationHomeSubClusterAppAlreadyExistsInTheSameSC() + throws Exception { + ApplicationId appId = ApplicationId.newInstance(1, 1); + SubClusterId subClusterId1 = SubClusterId.newInstance("SC1"); + addApplicationHomeSC(appId, subClusterId1); + + ApplicationHomeSubCluster ahsc2 = + ApplicationHomeSubCluster.newInstance(appId, subClusterId1); + + AddApplicationHomeSubClusterResponse response = + stateStore.addApplicationHomeSubCluster( + AddApplicationHomeSubClusterRequest.newInstance(ahsc2)); + + Assert.assertEquals(subClusterId1, response.getHomeSubCluster()); + Assert.assertEquals(subClusterId1, queryApplicationHomeSC(appId)); + + } + @Test public void testDeleteApplicationHomeSubCluster() throws Exception { ApplicationId appId = ApplicationId.newInstance(1, 1);