-
Couldn't load subscription status.
- Fork 9.1k
YARN-11290. Improve Query Condition of FederationStateStore#getApplicationsHomeSubCluster. #4846
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
Conversation
…ationsHomeSubCluster.
|
💔 -1 overall
This message was automatically generated. |
| appCount++; | ||
| } | ||
|
|
||
| GetApplicationsHomeSubClusterResponse.newInstance(result); |
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 was just overlooked?
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 line of code should be an extra line of code, which has no practical significance. The following is directly constructed and returned.
| SubClusterId requestSubClusterId = request.getSubClusterId(); | ||
| int appCount = 0; | ||
| for (int i = 0; i < applicationIdList.size(); i++) { | ||
| if (appCount >= maxAppsInStateStore) { |
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.
Move this to the for condition.
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.
Actually it would be good to do a foreach
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!
| if (requestSubClusterId != null && !requestSubClusterId.equals(subClusterId)){ | ||
| continue; | ||
| } | ||
| result.add(ApplicationHomeSubCluster.newInstance(applicationId, 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.
do the reverse if to avoid the continue
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 { | ||
| cstmt = getCallableStatement(CALL_SP_GET_APPLICATIONS_HOME_SUBCLUSTER); | ||
| cstmt.setInt("limit_IN", maxAppsInStateStore); | ||
| String homeSubClusterIN = 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.
Extra ;
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 the requestSubClusterId that needs to be filtered in the request | ||
| // is inconsistent with the SubClusterId in the data, continue to the next round | ||
| if (requestSubClusterId != null && !requestSubClusterId.equals(homeSubCluster)) { | ||
| continue; |
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.
reverse the if
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. |
|
This PR changes the execution script of the stored procedure, I will check the script against the major version of the database. SQLServer
MySQL MySQL-5.5 and MySQL-5.6 Can't Create Table membership and policies, for the following reasons: 1.The primary key of the membership table is subClusterId varchar(256) , Mysql will prompt the following error: 2.The primary key of the policies table is subClusterId varchar(256) , Mysql will prompt the following error:
|
|
🎊 +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! |
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +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! This PR changes the execution script of the stored procedure, I will check the script against the major version of the database. SQLServer
MySQL MySQL-5.5 and MySQL-5.6 Can't Create Table membership and policies, for the following reasons: 1.The primary key of the membership table is subClusterId varchar(256) , Mysql will prompt the following error: 2.The primary key of the policies table is subClusterId varchar(256) , Mysql will prompt the following error:
|
|
🎊 +1 overall
This message was automatically generated. |
| private boolean judgeAdd(SubClusterId filterSubCluster, SubClusterId homeSubCluster) { | ||
| if (filterSubCluster == null) { | ||
| return true; | ||
| } else if (filterSubCluster.equals(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.
No need for else
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 modify the code.
| return null; | ||
| } | ||
|
|
||
| private boolean judgeAdd(SubClusterId filterSubCluster, SubClusterId 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.
judgeAdd is a weird name fot this function.
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 re-select an appropriate method name.
| * | ||
| * @return the subcluster identifier | ||
| */ | ||
| @InterfaceAudience.Public |
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.
Use @public
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.
|
|
||
| Set<ApplicationHomeSubCluster> appHomeSubClusters = new HashSet<>(); | ||
|
|
||
| for (int i = 0; i < 10; i++) { |
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.
Make 10 and 20 constants.
...src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java
Show resolved
Hide resolved
| mockRMs.put(subClusterId, mockRM); | ||
| } | ||
| initNodeAttributes(subClusterId, mockRM); | ||
| initReservationSystem(mockRM); |
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 seems out of scope.
Should we do it in a separate PR?
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 submit pr separately to improve this code.
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 new pr will optimize the repetitive submission of reservations and refactor some test code.
|
🎊 +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. |
|
@goiri Please help to review the code again, thank you very much! I have provided a test report, we can refer to the following link MySQL
SQLServer
|
| IF(homeSubCluster_IN = '', 1, (homeSubCluster = homeSubCluster_IN)) AS filter_result | ||
| FROM applicationshomesubcluster | ||
| ORDER BY createTime DESC) AS app_home_sc | ||
| WHERE filter_result = 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.
Why you cannot do:
SELECT
applicationId,
homeSubCluster,
createTime
FROM applicationshomesubcluster
WHERE homeSubCluster_IN = '' OR homeSubCluster = homeSubCluster_IN
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 suggestion, I agree with you, I will modify the code.
| [createTime], | ||
| row_number() over(partition by [homeSubCluster] order by [createTime] desc) AS app_rank | ||
| FROM [dbo].[applicationsHomeSubCluster] | ||
| WHERE [homeSubCluster] = @homeSubCluster) AS t |
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
WHERE [homeSubCluster] = @homeSubCluster OR @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.
My code is a bit complicated, your approach is really good.
|
💔 -1 overall
This message was automatically generated. |
.../java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java
Show resolved
Hide resolved
| return null; | ||
| } | ||
|
|
||
| private boolean filterHomeSubCluster(SubClusterId filterSubCluster, |
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 have this function defined three times in three places.
It should also be static.
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
| [createTime], | ||
| row_number() over(order by [createTime] desc) AS app_rank | ||
| FROM [dbo].[applicationsHomeSubCluster] | ||
| WHERE [homeSubCluster] = @homeSubCluster OR @homeSubCluster = '') AS t |
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.
In the other one we use AS applicationshomesubcluster; let's try to be consistent with the names as possible.
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 helping to review the code, I will modify the code.
|
🎊 +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. |
|
@goiri Can you help merge this pr into trunk branch? Thank you very much! after this pr is completed, I will submit a new pr to clean up the completed application in the router's StateStore. |
|
@goiri Thank you very much for your help reviewing the code! |
…ationsHomeSubCluster. (apache#4846)
JIRA: YARN-11290. Improve Query Condition of FederationStateStore#getApplicationsHomeSubCluster.