YARN-5612. Return SubClusterId in FederationStateStoreFacade#addApplicationHomeSubCluster for Router Failover. (Giovanni Matteo Fumarola via Subru).
(cherry picked from commit ac1ba2a30427263f4a2eed2018515b2f759fa591)
This commit is contained in:
parent
94a24567d6
commit
1882bc10fb
@ -48,6 +48,7 @@
|
|||||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.FederationStateStore;
|
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.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.ApplicationHomeSubCluster;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterRequest;
|
import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterRequest;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterResponse;
|
import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterResponse;
|
||||||
@ -298,13 +299,15 @@ public Map<String, SubClusterPolicyConfiguration> getPoliciesConfigurations()
|
|||||||
*
|
*
|
||||||
* @param appHomeSubCluster the mapping of the application to it's home
|
* @param appHomeSubCluster the mapping of the application to it's home
|
||||||
* sub-cluster
|
* sub-cluster
|
||||||
|
* @return the stored Subcluster from StateStore
|
||||||
* @throws YarnException if the call to the state store is unsuccessful
|
* @throws YarnException if the call to the state store is unsuccessful
|
||||||
*/
|
*/
|
||||||
public void addApplicationHomeSubCluster(
|
public SubClusterId addApplicationHomeSubCluster(
|
||||||
ApplicationHomeSubCluster appHomeSubCluster) throws YarnException {
|
ApplicationHomeSubCluster appHomeSubCluster) throws YarnException {
|
||||||
stateStore.addApplicationHomeSubCluster(
|
AddApplicationHomeSubClusterResponse response =
|
||||||
AddApplicationHomeSubClusterRequest.newInstance(appHomeSubCluster));
|
stateStore.addApplicationHomeSubCluster(
|
||||||
return;
|
AddApplicationHomeSubClusterRequest.newInstance(appHomeSubCluster));
|
||||||
|
return response.getHomeSubCluster();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.FederationStateStore;
|
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.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.SubClusterId;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
|
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
|
||||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterPolicyConfiguration;
|
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterPolicyConfiguration;
|
||||||
@ -145,4 +146,33 @@ public void testGetHomeSubClusterForApp() throws YarnException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user