-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YARN-11236. Implement FederationReservationHomeSubClusterStore With MemoryStore. #4711
Conversation
💔 -1 overall
This message was automatically generated. |
@goiri Could you please help to review the code? Thank you very much! |
// note this might throw YarnException if the reservation is | ||
// unknown. This is to be expected, and should be handled by | ||
// policy invoker. | ||
SubClusterId resSubCluster = getPolicyContext().getFederationStateStoreFacade(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the facade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your help reviewing the code, I will fix it.
SubClusterId resSubCluster = getPolicyContext().getFederationStateStoreFacade(). | ||
getReservationHomeSubCluster(reservationId); | ||
|
||
return Collections.singletonMap(resSubCluster, activeSubClusters.get(resSubCluster)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
public AddReservationHomeSubClusterResponse addReservationHomeSubCluster( | ||
AddReservationHomeSubClusterRequest request) throws YarnException { | ||
FederationReservationHomeSubClusterStoreInputValidator | ||
.validateAddReservationHomeSubClusterRequest(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are pretty verose.
If we are in FederationReservationHomeSubClusterStoreInputValidator isn't enough to say validateRequest? or validate as the type is in the arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion, I have modified the code, the method is called validate()
* against | ||
* @throws FederationStateStoreInvalidInputException if the request is invalid | ||
*/ | ||
public static void validateGetReservationHomeSubClusterRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate() should be enough as the type is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified the code, the method is called validate()
private static void checkReservationId(ReservationId reservationId) | ||
throws FederationStateStoreInvalidInputException { | ||
if (reservationId == null) { | ||
String message = "Missing ReservationId." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
if (heartbeatInterval <= 0) { | ||
heartbeatInterval = | ||
YarnConfiguration.DEFAULT_FEDERATION_STATESTORE_HEARTBEAT_INTERVAL_SECS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave the these changes as they were?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@goiri Please help to review the code again, Thank you very much! |
if (!reservations.containsKey(reservationId)) { | ||
throw new YarnException("Reservation " + reservationId + " does not exist"); | ||
} | ||
return GetReservationHomeSubClusterResponse.newInstance( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractreservations.get(reservationId))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help reviewing the code, I will fix it.
GetReservationsHomeSubClusterRequest request) throws YarnException { | ||
List<ReservationHomeSubCluster> result = new ArrayList<>(); | ||
for (Entry<ReservationId, SubClusterId> e : reservations.entrySet()) { | ||
result.add(ReservationHomeSubCluster.newInstance(e.getKey(), e.getValue())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract key and value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the reservation actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
@Override | ||
public GetReservationHomeSubClusterResponse getReservationHomeSubCluster( | ||
GetReservationHomeSubClusterRequest request) throws YarnException { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we throw the not implemented exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
...n/java/org/apache/hadoop/yarn/server/federation/store/records/ReservationHomeSubCluster.java
Show resolved
Hide resolved
public SubClusterId getReservationHomeSubCluster(ReservationId reservationId) | ||
throws YarnException { | ||
GetReservationHomeSubClusterResponse response = | ||
stateStore.getReservationHomeSubCluster( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
// route an application that uses this app | ||
ApplicationSubmissionContext applicationSubmissionContext = | ||
ApplicationSubmissionContext.newInstance( | ||
ApplicationId.newInstance(System.currentTimeMillis(), 1), "app1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of out of scope but should we use Time.now()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
"queue1", Priority.newInstance(1), null, false, false, 1, null, | ||
null, false); | ||
applicationSubmissionContext.setReservationID(resReq.getReservationId()); | ||
SubClusterId chosen2 = ((FederationRouterPolicy) getPolicy()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's extract the router policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
💔 -1 overall
This message was automatically generated. |
@goiri Please help to review the code again, Thank you very much! |
public AddReservationHomeSubClusterResponse addReservationHomeSubCluster( | ||
AddReservationHomeSubClusterRequest request) throws YarnException { | ||
FederationReservationHomeSubClusterStoreInputValidator.validate(request); | ||
ReservationId reservationId = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
request.getReservationHomeSubCluster().getReservationId(); | ||
if (!reservations.containsKey(reservationId)) { | ||
reservations.put(reservationId, | ||
request.getReservationHomeSubCluster().getHomeSubCluster()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
} | ||
SubClusterId subClusterId = reservations.get(reservationId); | ||
return GetReservationHomeSubClusterResponse.newInstance( | ||
ReservationHomeSubCluster.newInstance(reservationId, subClusterId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
...ain/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java
Show resolved
Hide resolved
List<ReservationHomeSubCluster> result = new ArrayList<>(); | ||
|
||
for (Entry<ReservationId, SubClusterId> entry : reservations.entrySet()) { | ||
ReservationId key = entry.getKey(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better names than key/value; reservationId, subclusterId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
@Unstable | ||
public static ReservationHomeSubCluster newInstance(ReservationId appId, | ||
SubClusterId homeSubCluster) { | ||
ReservationHomeSubCluster appMapping = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
@Override | ||
public void setReservationId(ReservationId reservationId) { | ||
maybeInitBuilder(); | ||
if (reservationId == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't hide the field: resId as param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion, I will modify the code.
return null; | ||
} | ||
this.reservationId = convertFromProtoFormat(p.getReservationId()); | ||
return reservationId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.reservationId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
if (homeSubCluster == null) { | ||
builder.clearHomeSubCluster(); | ||
} | ||
this.homeSubCluster = homeSubCluster; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't hide the field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
long now = Time.now(); | ||
ReservationSubmissionRequest resReq = getReservationSubmissionRequest(); | ||
when(resReq.getQueue()).thenReturn("queue1"); | ||
when(resReq.getReservationId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
@goiri Please help to review the code again, Thank you very much! |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@goiri Can you help to merge this pr into trunk branch? I will follow up with YARN-11252, Thank you very much! |
Can we get a clean build? |
@goiri Thank you for your suggestion. I personally feel that this may be unavoidable, this part of the code is automatically generated.
We can check the following issue, the current version of protobuf does not seem to be able to solve it. I also checked the full compilation log, and I found that something like this is common. We can check the following link:
|
💔 -1 overall
This message was automatically generated. |
This reverts commit cbf67f5.
💔 -1 overall
This message was automatically generated. |
@goiri Thank you very much for your help reviewing the code! |
JIRA:YARN-11236. Implement FederationReservationHomeSubClusterStore With MemoryStore.
This pr mainly implements the methods of AddReservation and GetAddReservation. This version completes the basic logic first, and only implements the part of MemoryStore.