-
Notifications
You must be signed in to change notification settings - Fork 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-11219. [Federation] Add getAppActivities, getAppStatistics REST APIs for Router. #4757
Conversation
💔 -1 overall
This message was automatically generated. |
public void add(StatisticsItemInfo statItem) { | ||
this.statItem.add(statItem); | ||
} | ||
|
||
public ArrayList<StatisticsItemInfo> getStatItems() { | ||
return statItem; | ||
} | ||
|
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
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 interceptor.getAppActivities(hsrCopy, appId, time, requestPriorities, | ||
allocationRequestIds, groupBy, limit, actions, summarize); | ||
} catch (IllegalArgumentException e) { | ||
RouterServerUtil.logAndThrowRunTimeException(e, |
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.
String statisticsItemKey = statisticsItemInfo.getType() + "_" + statisticsItemInfo.getState().toString(); | ||
StatisticsItemInfo statisticsItemValue = | ||
statisticsItemMap.getOrDefault(statisticsItemKey, null); | ||
if (statisticsItemValue != 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.
Cleaner to do contains or similar.
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.
|
||
for (HashMap.Entry<ApplicationId, ApplicationReport> item : applicationMap.entrySet()) { | ||
|
||
ApplicationReport applicationReport = item.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.
If we don't do getKey, we can iterate .values()
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.
|
||
ArrayList<StatisticsItemInfo> itemInfos = new ArrayList<>(itemInfoMap.values()); | ||
|
||
return new ApplicationStatisticsInfo(itemInfos); |
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 do:
return new ApplicationStatisticsInfo(itemInfoMap.values());
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 suggestion, I will modify the code.
throw new NotFoundException("app with id: " + appId + " not found"); | ||
} | ||
|
||
SchedulerNode schedulerNode = |
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.
|
||
Assert.assertEquals(1, mergeInfo.getStatItems().size()); | ||
Assert.assertEquals(item1.getCount() + item2.getCount(), | ||
mergeInfo.getStatItems().get(0).getCount()); |
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 get(0) and check it first.
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.
🎊 +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! |
public void add(StatisticsItemInfo statItem) { | ||
this.statItem.add(statItem); | ||
} | ||
|
||
public ArrayList<StatisticsItemInfo> getStatItems() { | ||
return statItem; | ||
} | ||
|
||
} | ||
} |
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
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.
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ActiveUsersManager; | ||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; | ||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode; | ||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.*; |
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.
Expand
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! |
statisticsItemInfo.getType() + "_" + statisticsItemInfo.getState().toString(); | ||
|
||
StatisticsItemInfo statisticsItemValue; | ||
if(statisticsItemMap.containsKey(statisticsItemKey)) { |
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.
space after 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.
Thanks for your help reviewing the code, I will fix it.
interceptor.getAppStatistics(null, stateQueries, typeQueries); | ||
|
||
Assert.assertNotNull(response2); | ||
Assert.assertTrue(!response2.getStatItems().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.
assertFalse
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.
ApplicationStatisticsInfo infoA = new ApplicationStatisticsInfo(); | ||
ApplicationStatisticsInfo infoB = new ApplicationStatisticsInfo(); | ||
|
||
StatisticsItemInfo item1 = |
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.
@Test | ||
public void testMergeDiffApplicationStatisticsInfo() { | ||
ApplicationStatisticsInfo infoA = new ApplicationStatisticsInfo(); | ||
StatisticsItemInfo item1 = |
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.
RouterWebServiceUtil.mergeApplicationStatisticsInfo(lists); | ||
|
||
Assert.assertEquals(3, mergeInfo.getStatItems().size()); | ||
ArrayList<StatisticsItemInfo> mergeInfoStatItems = mergeInfo.getStatItems(); |
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.
List<StatisticsItemInfo> mergeInfoStatItems
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.
} | ||
} | ||
|
||
Assert.assertEquals(item1.getType(), item1Result.getType()); |
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 do:
assertEquals(YarnApplicationState.ACCEPTED, item1Result.getState());
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. |
@goiri Please help to review the code again, Thank you very much! |
@goiri Can you help to merge this pr into trunk branch? I will follow up with YARN-11226. Thank you very much! |
@goiri Thank you very much for helping to review the code! |
…APIs for Router. (apache#4757)
JIRA:YARN-11219. [Federation] Add getAppActivities, getAppStatistics REST APIs for Router.