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

This commit is contained in:
Inigo Goiri 2018-07-27 15:23:57 -07:00
parent 2cccf4061c
commit 79091cf76f
2 changed files with 26 additions and 7 deletions

View File

@ -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);

View File

@ -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);