[
https://issues.apache.org/jira/browse/YARN-11236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17576327#comment-17576327
]
ASF GitHub Bot commented on YARN-11236:
---------------------------------------
slfan1989 commented on code in PR #4711:
URL: https://github.com/apache/hadoop/pull/4711#discussion_r939616561
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java:
##########
@@ -400,6 +406,40 @@ public Configuration getConf() {
return this.conf;
}
+
+
+ /**
+ * Adds the home {@link SubClusterId} for the specified {@link
ReservationId}.
+ *
+ * @param appHomeSubCluster the mapping of the reservation to it's home
+ * sub-cluster
+ * @return the stored Subcluster from StateStore
+ * @throws YarnException if the call to the state store is unsuccessful
+ */
+ public SubClusterId addReservationHomeSubCluster(
+ ReservationHomeSubCluster appHomeSubCluster) throws YarnException {
+ AddReservationHomeSubClusterResponse response =
+ stateStore.addReservationHomeSubCluster(
+ AddReservationHomeSubClusterRequest.newInstance(appHomeSubCluster));
+ return response.getHomeSubCluster();
+ }
+
+ /**
+ * Returns the home {@link SubClusterId} for the specified
+ * {@link ReservationId}.
+ *
+ * @param reservationId the identifier of the reservation
+ * @return the home sub cluster identifier
+ * @throws YarnException if the call to the state store is unsuccessful
+ */
+ public SubClusterId getReservationHomeSubCluster(ReservationId reservationId)
+ throws YarnException {
+ GetReservationHomeSubClusterResponse response =
+ stateStore.getReservationHomeSubCluster(
Review Comment:
I will fix it.
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/BaseRouterPoliciesTest.java:
##########
@@ -126,4 +134,55 @@ public void testNullReservationContext() throws Exception {
() -> policy.getReservationHomeSubcluster(null));
}
+ @Test
+ public void testUnknownReservation() throws Exception {
+ ReservationSubmissionRequest resReq = getReservationSubmissionRequest();
+ ReservationId reservationId =
ReservationId.newInstance(System.currentTimeMillis(), 1);
+ when(resReq.getQueue()).thenReturn("queue1");
+ when(resReq.getReservationId()).thenReturn(reservationId);
+
+ // route an application that uses this app
+ ApplicationSubmissionContext applicationSubmissionContext =
+ ApplicationSubmissionContext.newInstance(
+ ApplicationId.newInstance(System.currentTimeMillis(), 1), "app1",
+ "queue1", Priority.newInstance(1), null, false, false, 1, null,
null, false);
+
+ applicationSubmissionContext.setReservationID(resReq.getReservationId());
+ FederationRouterPolicy policy = (FederationRouterPolicy) getPolicy();
+
+ LambdaTestUtils.intercept(YarnException.class,
+ "Reservation " + reservationId + " does not exist",
+ () -> policy.getHomeSubcluster(applicationSubmissionContext, new
ArrayList<>()));
+ }
+
+ @Test
+ public void testFollowReservation() throws YarnException {
+ ReservationSubmissionRequest resReq = getReservationSubmissionRequest();
+ when(resReq.getQueue()).thenReturn("queue1");
+ when(resReq.getReservationId())
+ .thenReturn(ReservationId.newInstance(System.currentTimeMillis(), 1));
+
+ // first we invoke a reservation placement
+ SubClusterId chosen = ((FederationRouterPolicy) getPolicy())
+ .getReservationHomeSubcluster(resReq);
+
+ // add this to the store
+ this.getFederationPolicyContext().getFederationStateStoreFacade()
+ .addReservationHomeSubCluster(ReservationHomeSubCluster.newInstance(
+ resReq.getReservationId(), chosen));
+
+ // route an application that uses this app
+ ApplicationSubmissionContext applicationSubmissionContext =
+ ApplicationSubmissionContext.newInstance(
+ ApplicationId.newInstance(System.currentTimeMillis(), 1), "app1",
Review Comment:
I will fix it.
> Implement FederationReservationHomeSubClusterStore With MemoryStore
> -------------------------------------------------------------------
>
> Key: YARN-11236
> URL: https://issues.apache.org/jira/browse/YARN-11236
> Project: Hadoop YARN
> Issue Type: Sub-task
> Components: federation
> Affects Versions: 3.4.0
> Reporter: fanshilun
> Assignee: fanshilun
> Priority: Major
> Labels: pull-request-available
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]