Skip to content

Commit a2c2eac

Browse files
slfan1989HarshitGupta11
authored andcommitted
YARN-11252. Yarn Federation Router Supports Update / Delete Reservation in MemoryStore. (apache#4741)
1 parent 9187ae9 commit a2c2eac

17 files changed

+906
-0
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/FederationReservationHomeSubClusterStore.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterResponse;
2727
import org.apache.hadoop.yarn.server.federation.store.records.AddReservationHomeSubClusterResponse;
2828
import org.apache.hadoop.yarn.server.federation.store.records.AddReservationHomeSubClusterRequest;
29+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterRequest;
30+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterResponse;
31+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterRequest;
32+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterResponse;
2933

3034
/**
3135
* FederationReservationHomeSubClusterStore maintains the state of all
@@ -86,4 +90,30 @@ GetReservationHomeSubClusterResponse getReservationHomeSubCluster(
8690
GetReservationsHomeSubClusterResponse getReservationsHomeSubCluster(
8791
GetReservationsHomeSubClusterRequest request) throws YarnException;
8892

93+
/**
94+
* Update the home {@code SubClusterId} of a previously submitted
95+
* {@code ReservationId}. Currently response is empty if the operation was
96+
* successful, if not an exception reporting reason for a failure.
97+
*
98+
* @param request the request to update the home sub-cluster of a reservation.
99+
* @return empty on successful update of the Reservation in the StateStore, if
100+
* not an exception reporting reason for a failure
101+
* @throws YarnException if the request is invalid/fails
102+
*/
103+
UpdateReservationHomeSubClusterResponse updateReservationHomeSubCluster(
104+
UpdateReservationHomeSubClusterRequest request) throws YarnException;
105+
106+
107+
/**
108+
* Delete the mapping of home {@code SubClusterId} of a previously submitted
109+
* {@code ReservationId}. Currently response is empty if the operation was
110+
* successful, if not an exception reporting reason for a failure.
111+
*
112+
* @param request the request to delete the home sub-cluster of a reservation.
113+
* @return empty on successful update of the Reservation in the StateStore, if
114+
* not an exception reporting reason for a failure
115+
* @throws YarnException if the request is invalid/fails
116+
*/
117+
DeleteReservationHomeSubClusterResponse deleteReservationHomeSubCluster(
118+
DeleteReservationHomeSubClusterRequest request) throws YarnException;
89119
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterResponse;
6868
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterRequest;
6969
import org.apache.hadoop.yarn.server.federation.store.records.ReservationHomeSubCluster;
70+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterRequest;
71+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterResponse;
72+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterRequest;
73+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterResponse;
7074
import org.apache.hadoop.yarn.server.federation.store.utils.FederationApplicationHomeSubClusterStoreInputValidator;
7175
import org.apache.hadoop.yarn.server.federation.store.utils.FederationReservationHomeSubClusterStoreInputValidator;
7276
import org.apache.hadoop.yarn.server.federation.store.utils.FederationMembershipStateStoreInputValidator;
@@ -365,4 +369,31 @@ public GetReservationsHomeSubClusterResponse getReservationsHomeSubCluster(
365369

366370
return GetReservationsHomeSubClusterResponse.newInstance(result);
367371
}
372+
373+
@Override
374+
public UpdateReservationHomeSubClusterResponse updateReservationHomeSubCluster(
375+
UpdateReservationHomeSubClusterRequest request) throws YarnException {
376+
FederationReservationHomeSubClusterStoreInputValidator.validate(request);
377+
ReservationId reservationId = request.getReservationHomeSubCluster().getReservationId();
378+
379+
if (!reservations.containsKey(reservationId)) {
380+
throw new YarnException("Reservation " + reservationId + " does not exist.");
381+
}
382+
383+
SubClusterId subClusterId = request.getReservationHomeSubCluster().getHomeSubCluster();
384+
reservations.put(reservationId, subClusterId);
385+
return UpdateReservationHomeSubClusterResponse.newInstance();
386+
}
387+
388+
@Override
389+
public DeleteReservationHomeSubClusterResponse deleteReservationHomeSubCluster(
390+
DeleteReservationHomeSubClusterRequest request) throws YarnException {
391+
FederationReservationHomeSubClusterStoreInputValidator.validate(request);
392+
ReservationId reservationId = request.getReservationId();
393+
if (!reservations.containsKey(reservationId)) {
394+
throw new YarnException("Reservation " + reservationId + " does not exist");
395+
}
396+
reservations.remove(reservationId);
397+
return DeleteReservationHomeSubClusterResponse.newInstance();
398+
}
368399
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationHomeSubClusterRequest;
7575
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterResponse;
7676
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterRequest;
77+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterRequest;
78+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterResponse;
79+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterRequest;
80+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterResponse;
7781
import org.apache.hadoop.yarn.server.federation.store.utils.FederationApplicationHomeSubClusterStoreInputValidator;
7882
import org.apache.hadoop.yarn.server.federation.store.utils.FederationMembershipStateStoreInputValidator;
7983
import org.apache.hadoop.yarn.server.federation.store.utils.FederationPolicyStoreInputValidator;
@@ -1027,4 +1031,16 @@ public GetReservationsHomeSubClusterResponse getReservationsHomeSubCluster(
10271031
GetReservationsHomeSubClusterRequest request) throws YarnException {
10281032
throw new NotImplementedException("Code is not implemented");
10291033
}
1034+
1035+
@Override
1036+
public DeleteReservationHomeSubClusterResponse deleteReservationHomeSubCluster(
1037+
DeleteReservationHomeSubClusterRequest request) throws YarnException {
1038+
throw new NotImplementedException("Code is not implemented");
1039+
}
1040+
1041+
@Override
1042+
public UpdateReservationHomeSubClusterResponse updateReservationHomeSubCluster(
1043+
UpdateReservationHomeSubClusterRequest request) throws YarnException {
1044+
throw new NotImplementedException("Code is not implemented");
1045+
}
10301046
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationHomeSubClusterRequest;
7373
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterResponse;
7474
import org.apache.hadoop.yarn.server.federation.store.records.GetReservationsHomeSubClusterRequest;
75+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterRequest;
76+
import org.apache.hadoop.yarn.server.federation.store.records.DeleteReservationHomeSubClusterResponse;
77+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterRequest;
78+
import org.apache.hadoop.yarn.server.federation.store.records.UpdateReservationHomeSubClusterResponse;
7579
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterIdPBImpl;
7680
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterInfoPBImpl;
7781
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterPolicyConfigurationPBImpl;
@@ -662,4 +666,16 @@ public GetReservationsHomeSubClusterResponse getReservationsHomeSubCluster(
662666
GetReservationsHomeSubClusterRequest request) throws YarnException {
663667
throw new NotImplementedException("Code is not implemented");
664668
}
669+
670+
@Override
671+
public DeleteReservationHomeSubClusterResponse deleteReservationHomeSubCluster(
672+
DeleteReservationHomeSubClusterRequest request) throws YarnException {
673+
throw new NotImplementedException("Code is not implemented");
674+
}
675+
676+
@Override
677+
public UpdateReservationHomeSubClusterResponse updateReservationHomeSubCluster(
678+
UpdateReservationHomeSubClusterRequest request) throws YarnException {
679+
throw new NotImplementedException("Code is not implemented");
680+
}
665681
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
package org.apache.hadoop.yarn.server.federation.store.records;
19+
20+
import org.apache.hadoop.classification.InterfaceAudience.Private;
21+
import org.apache.hadoop.classification.InterfaceAudience.Public;
22+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
23+
import org.apache.hadoop.yarn.api.records.ReservationId;
24+
import org.apache.hadoop.yarn.util.Records;
25+
26+
/**
27+
* The request to <code>Federation state store</code> to delete the mapping of
28+
* home subcluster of a submitted reservation.
29+
*/
30+
@Private
31+
@Unstable
32+
public abstract class DeleteReservationHomeSubClusterRequest {
33+
34+
@Private
35+
@Unstable
36+
public static DeleteReservationHomeSubClusterRequest newInstance(
37+
ReservationId reservationId) {
38+
DeleteReservationHomeSubClusterRequest deleteReservationRequest =
39+
Records.newRecord(DeleteReservationHomeSubClusterRequest.class);
40+
deleteReservationRequest.setReservationId(reservationId);
41+
return deleteReservationRequest;
42+
}
43+
44+
/**
45+
* Get the identifier of the {@link ReservationId} to be removed from
46+
* <code>Federation state store</code> .
47+
*
48+
* @return the identifier of the Reservation to be removed from Federation
49+
* State Store.
50+
*/
51+
@Public
52+
@Unstable
53+
public abstract ReservationId getReservationId();
54+
55+
/**
56+
* Set the identifier of the {@link ReservationId} to be removed from
57+
* <code>Federation state store</code> .
58+
*
59+
* @param reservationId the identifier of the Reservation to be removed from
60+
* Federation State Store.
61+
*/
62+
@Private
63+
@Unstable
64+
public abstract void setReservationId(ReservationId reservationId);
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
package org.apache.hadoop.yarn.server.federation.store.records;
19+
20+
import org.apache.hadoop.classification.InterfaceAudience.Private;
21+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
22+
import org.apache.hadoop.yarn.util.Records;
23+
24+
/**
25+
* DeleteReservationHomeSubClusterResponse contains the answer from the {@code
26+
* FederationReservationHomeSubClusterStore} to a request to delete the mapping
27+
* of home subcluster of a submitted reservation. Currently, response is empty if
28+
* the operation was successful, if not an exception reporting reason for a
29+
* failure.
30+
*/
31+
@Private
32+
@Unstable
33+
public abstract class DeleteReservationHomeSubClusterResponse {
34+
35+
@Private
36+
@Unstable
37+
public static DeleteReservationHomeSubClusterResponse newInstance() {
38+
DeleteReservationHomeSubClusterResponse response =
39+
Records.newRecord(DeleteReservationHomeSubClusterResponse.class);
40+
return response;
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
package org.apache.hadoop.yarn.server.federation.store.records;
19+
20+
import org.apache.hadoop.classification.InterfaceAudience.Private;
21+
import org.apache.hadoop.classification.InterfaceAudience.Public;
22+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
23+
import org.apache.hadoop.yarn.util.Records;
24+
25+
/**
26+
* <p>
27+
* The request sent by the <code>Router</code> to
28+
* <code>Federation state store</code> to update the home subcluster of a newly
29+
* submitted reservation.
30+
*
31+
* <p>
32+
* The request includes the mapping details, i.e.:
33+
* <ul>
34+
* <li>{@code ReservationId}</li>
35+
* <li>{@code SubClusterId}</li>
36+
* </ul>
37+
*/
38+
@Private
39+
@Unstable
40+
public abstract class UpdateReservationHomeSubClusterRequest {
41+
42+
@Private
43+
@Unstable
44+
public static UpdateReservationHomeSubClusterRequest newInstance(
45+
ReservationHomeSubCluster reservationHomeSubCluster) {
46+
UpdateReservationHomeSubClusterRequest updateReservationRequest =
47+
Records.newRecord(UpdateReservationHomeSubClusterRequest.class);
48+
updateReservationRequest
49+
.setReservationHomeSubCluster(reservationHomeSubCluster);
50+
return updateReservationRequest;
51+
}
52+
53+
/**
54+
* Get the {@link ReservationHomeSubCluster} representing the mapping of the
55+
* reservation to it's home sub-cluster.
56+
*
57+
* @return the mapping of the reservation to it's home sub-cluster.
58+
*/
59+
@Public
60+
@Unstable
61+
public abstract ReservationHomeSubCluster getReservationHomeSubCluster();
62+
63+
/**
64+
* Set the {@link ReservationHomeSubCluster} representing the mapping of the
65+
* reservation to it's home sub-cluster.
66+
*
67+
* @param reservationHomeSubCluster the mapping of the reservation to it's
68+
* home sub-cluster.
69+
*/
70+
@Private
71+
@Unstable
72+
public abstract void setReservationHomeSubCluster(
73+
ReservationHomeSubCluster reservationHomeSubCluster);
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
package org.apache.hadoop.yarn.server.federation.store.records;
19+
20+
import org.apache.hadoop.classification.InterfaceAudience.Private;
21+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
22+
import org.apache.hadoop.yarn.util.Records;
23+
24+
/**
25+
* UpdateReservationHomeSubClusterResponse contains the answer from the
26+
* {@code FederationReservationHomeSubClusterStore} to a request to register the
27+
* home subcluster of a submitted reservation. Currently response is empty if
28+
* the operation was successful, if not an exception reporting reason for a
29+
* failure.
30+
*/
31+
@Private
32+
@Unstable
33+
public abstract class UpdateReservationHomeSubClusterResponse {
34+
35+
@Private
36+
@Unstable
37+
public static UpdateReservationHomeSubClusterResponse newInstance() {
38+
UpdateReservationHomeSubClusterResponse response =
39+
Records.newRecord(UpdateReservationHomeSubClusterResponse.class);
40+
return response;
41+
}
42+
43+
}

0 commit comments

Comments
 (0)