YARN-5612. Return SubClusterId in FederationStateStoreFacade#addApplicationHomeSubCluster for Router Failover. (Giovanni Matteo Fumarola via Subru).

This commit is contained in:
Subru Krishnan 2016-09-01 13:55:54 -07:00 committed by Carlo Curino
parent 8573c286e2
commit ac1ba2a304
2 changed files with 37 additions and 4 deletions

View File

@ -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();
}
/**

View File

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