-
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-10829. Support getApplications API in FederationClientInterceptor #3135
Conversation
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@goiri @bibinchundatt Could you kindly help in reviewing this PR? Thanks. |
🎊 +1 overall
This message was automatically generated. |
@@ -196,6 +197,13 @@ public void init(String userName) { | |||
clientRMProxies = | |||
new ConcurrentHashMap<SubClusterId, ApplicationClientProtocol>(); | |||
routerMetrics = RouterMetrics.getMetrics(); | |||
|
|||
returnPartialReport = |
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.
The lines could be split in a more friendly way:
returnPartialReport = | |
returnPartialReport = conf.getBoolean( | |
YarnConfiguration.ROUTER_CLIENTRM_PARTIAL_RESULTS_ENABLED, | |
YarnConfiguration.DEFAULT_ROUTER_CLIENTRM_PARTIAL_RESULTS_ENABLED); |
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.
Done.
throw new NotImplementedException("Code is not implemented"); | ||
if (request == null) { | ||
RouterServerUtil.logAndThrowException( | ||
"Missing getApplications 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.
I don't think the spacing follows the right convention.
The checkstyle should flag all this.
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.
There were no flags in checkstyle. I have applied Hadoop formatter and ensure that checkstyle plugin is not giving any errors.
invokeConcurrent(clusterIds, remoteMethod, | ||
GetApplicationsResponse.class); | ||
|
||
//Merge the Application Reports |
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.
//Merge the Application Reports | |
// Merge the Application Reports |
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.
Fixed.
Map<ApplicationId, ApplicationReport> federationAM = new HashMap<>(); | ||
Map<ApplicationId, ApplicationReport> federationUAMSum = new HashMap<>(); | ||
|
||
for(GetApplicationsResponse appResponse : responses){ |
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.
for(GetApplicationsResponse appResponse : responses){ | |
for (GetApplicationsResponse appResponse : responses){ |
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.
Fixed.
} | ||
// This ApplicationReport is an UAM | ||
} else { | ||
if (federationAM.containsKey(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.
if (federationAM.containsKey(appId)) { | |
} else if (federationAM.containsKey(appId)) { |
And then the rest of the elses would go with this.
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.
Done.
...test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java
Show resolved
Hide resolved
newInstance(appTypes)); | ||
|
||
Assert.assertNotNull(responseGet); | ||
Assert.assertEquals(0, responseGet.getApplicationList().size()); |
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.
Assert.assertEquals(0, responseGet.getApplicationList().size()); | |
Assert.assertTrue(responseGet.getApplicationList().isEmpty()); |
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.
Done.
|
||
GetApplicationsResponse responseGet = | ||
interceptor.getApplications( | ||
GetApplicationsRequest. |
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.
Done.
...r/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestRouterYarnClientUtils.java
Outdated
Show resolved
Hide resolved
null); | ||
|
||
//Add unmanaged application to list | ||
ApplicationId applicationId2 = ApplicationId.newInstance(1234, |
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.
You could use shorter names like appId2
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.
Done.
🎊 +1 overall
This message was automatically generated. |
@goiri Thanks for providing your comments. I have addressed the comments. Could you kindly help in re-reviewing? |
@@ -184,6 +184,8 @@ public void initializeMemberVariables() { | |||
|
|||
configurationPrefixToSkipCompare | |||
.add(YarnConfiguration.ROUTER_CLIENTRM_SUBMIT_RETRY); | |||
configurationPrefixToSkipCompare | |||
.add(YarnConfiguration.ROUTER_CLIENTRM_PARTIAL_RESULTS_ENABLED); |
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.
Match the indentation with the previous one.
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.
Fixed.
new Class[] {GetApplicationsRequest.class}, new Object[] {request}); | ||
ArrayList<SubClusterId> clusterIds = new ArrayList<>(subclusters.keySet()); | ||
Map<SubClusterId, GetApplicationsResponse> applications = | ||
invokeConcurrent(clusterIds, remoteMethod, |
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.
This probably fits in a 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.
After using Collection directly, it does not fit in a single line.
} else if (federationUAMSum.containsKey(appId)) { | ||
// Merge the current UAM with its own UAM and update the list of UAM | ||
federationUAMSum.put(appId, | ||
mergeUAMWithUAM(federationUAMSum.get(appId), appReport)); |
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 result of the merge.
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.
Done.
private static boolean mergeUamToReport(String appName, | ||
boolean returnPartialResult){ | ||
|
||
return returnPartialResult || (appName != 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.
To make it more readable you could do somethin like:
if (returnPartialResult) {
return true;
}
if (appName == null) {
return false;
}
...
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.
Updated.
@Test | ||
public void testGetApplicationsResponse() | ||
throws YarnException, IOException, InterruptedException { | ||
LOG.info("Test FederationClientInterceptor: " + |
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 mean that putting the whole thing would fit in 80:
LOG.info("Test FederationClientInterceptor: Get Applications Response");
federationFacade.getSubClusters(true); | ||
ClientMethod remoteMethod = new ClientMethod("getApplications", | ||
new Class[] {GetApplicationsRequest.class}, new Object[] {request}); | ||
ArrayList<SubClusterId> clusterIds = new ArrayList<>(subclusters.keySet()); |
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'm pretty sure we are doing this conversion to list a bunch of times, having one that takes Collection would remove some noise.
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.
Overloaded the invokeConcurrent
method to take Collection
. Will update the other usage in a follow up PR once this is merged.
ApplicationId appId2 = ApplicationId.newInstance(1234, | ||
value); | ||
ApplicationReport appReport2 = ApplicationReport.newInstance( | ||
appId2, ApplicationAttemptId.newInstance(appId2, |
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.
newInstace() in a 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.
Done.
|
||
ApplicationReport appReport = ApplicationReport.newInstance( | ||
appId, ApplicationAttemptId.newInstance(appId, | ||
1), |
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.
Done.
List<ApplicationReport> applications = new ArrayList<>(); | ||
|
||
//Add managed application to list | ||
ApplicationId appId = ApplicationId.newInstance(1234, |
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.
Done.
null); | ||
|
||
//Add unmanaged application to list | ||
ApplicationId appId2 = ApplicationId.newInstance(1234, |
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.
Done.
@goiri I have addressed the further comments. Please take a look whenever you get a chance. Thanks. |
🎊 +1 overall
This message was automatically generated. |
@@ -196,6 +198,10 @@ public void init(String userName) { | |||
clientRMProxies = | |||
new ConcurrentHashMap<SubClusterId, ApplicationClientProtocol>(); | |||
routerMetrics = RouterMetrics.getMetrics(); | |||
|
|||
returnPartialReport = conf.getBoolean( |
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.
Extra space before =
@@ -675,6 +715,11 @@ public Object call() throws Exception { | |||
} | |||
return results; | |||
} | |||
<R> Map<SubClusterId, R> invokeConcurrent(Collection<SubClusterId> clusterIds, |
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.
Add break line right before the method definition.
🎊 +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. |
...outer/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java
Show resolved
Hide resolved
...outer/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java
Show resolved
Hide resolved
...outer/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java
Outdated
Show resolved
Hide resolved
apache#3135) YARN-10829. Support getApplications API in FederationClientInterceptor (apache#3135)
Implementing getApplications API in FederationClientInterceptors.
Unit tests are running successfully on dev machine.