Skip to content

Commit

Permalink
YARN-11219. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Aug 19, 2022
1 parent ac69043 commit 5787b7b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public void add(StatisticsItemInfo statItem) {
public ArrayList<StatisticsItemInfo> getStatItems() {
return statItem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,8 @@ public AppActivitiesInfo getAppActivities(HttpServletRequest hsr,
return interceptor.getAppActivities(hsrCopy, appId, time, requestPriorities,
allocationRequestIds, groupBy, limit, actions, summarize);
} catch (IllegalArgumentException e) {
RouterServerUtil.logAndThrowRunTimeException(e,
"Unable to get subCluster by appId: %s.", appId);
RouterServerUtil.logAndThrowRunTimeException(e, "Unable to get subCluster by appId: %s.",
appId);
} catch (YarnException e) {
RouterServerUtil.logAndThrowRunTimeException("getAppActivities Failed.", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,21 @@ public static ApplicationStatisticsInfo mergeApplicationStatisticsInfo(
appStatistics.stream().forEach(appStatistic -> {
List<StatisticsItemInfo> statisticsItemInfos = appStatistic.getStatItems();
for (StatisticsItemInfo statisticsItemInfo : statisticsItemInfos) {

String statisticsItemKey =
statisticsItemInfo.getType() + "_" + statisticsItemInfo.getState().toString();
StatisticsItemInfo statisticsItemValue =
statisticsItemMap.getOrDefault(statisticsItemKey, null);
if (statisticsItemValue != null) {

StatisticsItemInfo statisticsItemValue;
if(statisticsItemMap.containsKey(statisticsItemKey)) {
statisticsItemValue = statisticsItemMap.get(statisticsItemKey);
long statisticsItemValueCount = statisticsItemValue.getCount();
long statisticsItemInfoCount = statisticsItemInfo.getCount();
long newCount = statisticsItemValueCount + statisticsItemInfoCount;
statisticsItemValue.setCount(newCount);
} else {
statisticsItemValue = new StatisticsItemInfo(statisticsItemInfo);
}

statisticsItemMap.put(statisticsItemKey, statisticsItemValue);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,10 @@ public ApplicationStatisticsInfo getAppStatistics(

Map<String, StatisticsItemInfo> itemInfoMap = new HashMap<>();

for (HashMap.Entry<ApplicationId, ApplicationReport> item : applicationMap.entrySet()) {
for (ApplicationReport appReport : applicationMap.values()) {

ApplicationReport applicationReport = item.getValue();
YarnApplicationState appState = applicationReport.getYarnApplicationState();
String appType = applicationReport.getApplicationType();
YarnApplicationState appState = appReport.getYarnApplicationState();
String appType = appReport.getApplicationType();

if (stateQueries.contains(appState.name()) && typeQueries.contains(appType)) {
String itemInfoMapKey = appState.toString() + "_" + appType;
Expand All @@ -723,9 +722,7 @@ public ApplicationStatisticsInfo getAppStatistics(
}
}

ArrayList<StatisticsItemInfo> itemInfos = new ArrayList<>(itemInfoMap.values());

return new ApplicationStatisticsInfo(itemInfos);
return new ApplicationStatisticsInfo(itemInfoMap.values());
}

@Override
Expand All @@ -742,8 +739,7 @@ public AppActivitiesInfo getAppActivities(
throw new NotFoundException("app with id: " + appId + " not found");
}

SchedulerNode schedulerNode =
TestUtils.getMockNode("host0", "rack", 1, 10240);
SchedulerNode schedulerNode = TestUtils.getMockNode("host0", "rack", 1, 10240);

RMContext rmContext = Mockito.mock(RMContext.class);
Mockito.when(rmContext.getYarnConfiguration()).thenReturn(this.getConf());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,14 +614,16 @@ public void testMergeApplicationStatisticsInfo() {

ApplicationStatisticsInfo mergeInfo =
RouterWebServiceUtil.mergeApplicationStatisticsInfo(lists);
ArrayList<StatisticsItemInfo> statItem = mergeInfo.getStatItems();

Assert.assertEquals(1, mergeInfo.getStatItems().size());
Assert.assertEquals(item1.getCount() + item2.getCount(),
mergeInfo.getStatItems().get(0).getCount());
Assert.assertEquals(item1.getType(),
mergeInfo.getStatItems().get(0).getType());
Assert.assertEquals(item1.getState(),
mergeInfo.getStatItems().get(0).getState());
Assert.assertNotNull(statItem);
Assert.assertEquals(1, statItem.size());

StatisticsItemInfo first = statItem.get(0);

Assert.assertEquals(item1.getCount() + item2.getCount(), first.getCount());
Assert.assertEquals(item1.getType(), first.getType());
Assert.assertEquals(item1.getState(), first.getState());
}

@Test
Expand Down

0 comments on commit 5787b7b

Please sign in to comment.