YARN-10829. Support getApplications API in FederationClientInterceptor#3135
YARN-10829. Support getApplications API in FederationClientInterceptor#3135bibinchundatt merged 11 commits intoapache:trunkfrom akshatb1:trunk
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. |
| new ConcurrentHashMap<SubClusterId, ApplicationClientProtocol>(); | ||
| routerMetrics = RouterMetrics.getMetrics(); | ||
|
|
||
| returnPartialReport = |
There was a problem hiding this comment.
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); |
| throw new NotImplementedException("Code is not implemented"); | ||
| if (request == null) { | ||
| RouterServerUtil.logAndThrowException( | ||
| "Missing getApplications request.", |
There was a problem hiding this comment.
I don't think the spacing follows the right convention.
The checkstyle should flag all this.
There was a problem hiding this comment.
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.
| //Merge the Application Reports | |
| // Merge the Application Reports |
| Map<ApplicationId, ApplicationReport> federationAM = new HashMap<>(); | ||
| Map<ApplicationId, ApplicationReport> federationUAMSum = new HashMap<>(); | ||
|
|
||
| for(GetApplicationsResponse appResponse : responses){ |
There was a problem hiding this comment.
| for(GetApplicationsResponse appResponse : responses){ | |
| for (GetApplicationsResponse appResponse : responses){ |
| } | ||
| // This ApplicationReport is an UAM | ||
| } else { | ||
| if (federationAM.containsKey(appId)) { |
There was a problem hiding this comment.
| if (federationAM.containsKey(appId)) { | |
| } else if (federationAM.containsKey(appId)) { |
And then the rest of the elses would go with this.
...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.
| Assert.assertEquals(0, responseGet.getApplicationList().size()); | |
| Assert.assertTrue(responseGet.getApplicationList().isEmpty()); |
|
|
||
| GetApplicationsResponse responseGet = | ||
| interceptor.getApplications( | ||
| GetApplicationsRequest. |
...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.
You could use shorter names like appId2
|
🎊 +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? |
| configurationPrefixToSkipCompare | ||
| .add(YarnConfiguration.ROUTER_CLIENTRM_SUBMIT_RETRY); | ||
| configurationPrefixToSkipCompare | ||
| .add(YarnConfiguration.ROUTER_CLIENTRM_PARTIAL_RESULTS_ENABLED); |
There was a problem hiding this comment.
Match the indentation with the previous one.
| 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.
This probably fits in a single line
There was a problem hiding this comment.
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)); |
| private static boolean mergeUamToReport(String appName, | ||
| boolean returnPartialResult){ | ||
|
|
||
| return returnPartialResult || (appName != null && |
There was a problem hiding this comment.
To make it more readable you could do somethin like:
if (returnPartialResult) {
return true;
}
if (appName == null) {
return false;
}
...
| @Test | ||
| public void testGetApplicationsResponse() | ||
| throws YarnException, IOException, InterruptedException { | ||
| LOG.info("Test FederationClientInterceptor: " + |
There was a problem hiding this comment.
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.
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.
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, |
|
|
||
| ApplicationReport appReport = ApplicationReport.newInstance( | ||
| appId, ApplicationAttemptId.newInstance(appId, | ||
| 1), |
| List<ApplicationReport> applications = new ArrayList<>(); | ||
|
|
||
| //Add managed application to list | ||
| ApplicationId appId = ApplicationId.newInstance(1234, |
| null); | ||
|
|
||
| //Add unmanaged application to list | ||
| ApplicationId appId2 = ApplicationId.newInstance(1234, |
|
@goiri I have addressed the further comments. Please take a look whenever you get a chance. Thanks. |
|
🎊 +1 overall
This message was automatically generated. |
| new ConcurrentHashMap<SubClusterId, ApplicationClientProtocol>(); | ||
| routerMetrics = RouterMetrics.getMetrics(); | ||
|
|
||
| returnPartialReport = conf.getBoolean( |
| } | ||
| return results; | ||
| } | ||
| <R> Map<SubClusterId, R> invokeConcurrent(Collection<SubClusterId> clusterIds, |
There was a problem hiding this comment.
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.