Browse Source

YARN-8596. Allow SQLFederationStateStore to submit the same app in the same subcluster. Contributed by Giovanni Matteo Fumarola.

Inigo Goiri 6 năm trước cách đây
mục cha
commit
79091cf76f

+ 7 - 7
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 class SQLFederationStateStore implements FederationStateStore {
         // 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);

+ 19 - 0
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 abstract class FederationStateStoreBaseTest {
 
   }
 
+  @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);