-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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-11442. Refactor FederationInterceptorREST Code. #5420
Conversation
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@@ -736,6 +726,9 @@ public AppsInfo getApps(HttpServletRequest hsr, String stateQuery, | |||
// HttpServletRequest does not work with ExecutorCompletionService. | |||
// Create a duplicate hsr. | |||
final HttpServletRequest hsrCopy = clone(hsr); | |||
|
|||
|
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.
Needed three break lines?
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 for your help to review the code, I will modify the code. This part of the code, I need to continue to improve.
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@@ -968,7 +969,7 @@ public int getActiveSubClustersCount() throws YarnException { | |||
* @throws YarnException When there is no Active SubCluster, | |||
* an exception will be thrown (No active SubCluster available to submit the request.) | |||
*/ | |||
public static SubClusterId getRandomActiveSubCluster( | |||
public SubClusterId getRandomActiveSubCluster( |
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.
Isn't this still static?
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.
We should change the places where we call it to call it as static.
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 to review the code! This part of the code can continue to be static, I will modify the code.
@@ -2318,7 +2220,7 @@ public Response createNewReservation(HttpServletRequest hsr) | |||
|
|||
private Response invokeCreateNewReservation(Map<SubClusterId, SubClusterInfo> subClustersActive, | |||
List<SubClusterId> blackList, HttpServletRequest hsr, int retryCount) | |||
throws YarnException, IOException, InterruptedException { | |||
throws YarnException { | |||
SubClusterId subClusterId = | |||
federationFacade.getRandomActiveSubCluster(subClustersActive, blackList); |
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.
Just make this call static.
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.
try { | ||
applicationId = ApplicationId.fromString(appId); | ||
ApplicationId.fromString(appId); |
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.
Why do we do this if we don't use it?
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 the reminder, I will improve this part of the code again.
getOrCreateInterceptorForSubCluster(subClusterId, | ||
subClusterInfo.getRMWebServiceAddress()); | ||
// Call the appState interface. | ||
DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster(subClusterInfo); |
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.
As you are consolidating, you could create methods with appId and nodeId.
@@ -1451,7 +1361,7 @@ public AppActivitiesInfo getAppActivities(HttpServletRequest hsr, | |||
long startTime = clock.getTime(); | |||
SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(appId); |
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.
Create one with appId and then you do the proper check for null, etc.
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 modify the code.
@@ -641,7 +632,7 @@ public void testGetApplicationState() | |||
*/ | |||
@Test | |||
public void testGetApplicationStateNotExists() |
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.
One line?
@@ -1262,6 +1250,7 @@ public void testSubmitReservation() throws Exception { | |||
Assert.assertNotNull(entity); | |||
Assert.assertNotNull(entity instanceof ReservationListInfo); | |||
|
|||
assert entity instanceof ReservationListInfo; |
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.
Do a junit Assert.assertTrue()
💔 -1 overall
This message was automatically generated. |
@@ -198,16 +200,14 @@ public void init(String user) { | |||
throw new YarnRuntimeException(e); | |||
} | |||
|
|||
numSubmitRetries = conf.getInt( | |||
YarnConfiguration.ROUTER_CLIENTRM_SUBMIT_RETRY, | |||
numSubmitRetries = conf.getInt(YarnConfiguration.ROUTER_CLIENTRM_SUBMIT_RETRY, |
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.
Avoid this change. It looked ok before.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
|
||
protected DefaultRequestInterceptorREST getOrCreateInterceptorByAppId(String appId) | ||
throws YarnException { | ||
SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(appId); |
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.
Why not doing the validation of the appId here?
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.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@goiri Thank you very much for helping to review the code! |
JIRA: YARN-11442. Refactor FederationInterceptorREST Code.
Fix code issues to make code more readable