ZanderXu commented on code in PR #8677:
URL: https://github.com/apache/hadoop/pull/8677#discussion_r3782852753
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/top/window/RollingWindowManager.java:
##########
@@ -298,54 +313,23 @@ public TopWindow snapshot(long time) {
private UserCounts getTopUsersForMetric(long time, String metricName,
RollingWindowMap rollingWindows) {
UserCounts topN = new UserCounts(topUsersCnt);
- Iterator<Map.Entry<String, RollingWindow>> iterator =
- rollingWindows.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry<String, RollingWindow> entry = iterator.next();
- String userName = entry.getKey();
- RollingWindow aWindow = entry.getValue();
- long windowSum = aWindow.getSum(time);
- // do the gc here
- if (windowSum == 0) {
- LOG.debug("gc window of metric: {} userName: {}",
- metricName, userName);
- iterator.remove();
- continue;
- }
- LOG.debug("offer window of metric: {} userName: {} sum: {}",
- metricName, userName, windowSum);
- topN.add(new User(userName, windowSum));
+ for (String userName : rollingWindows.keySet()) {
+ rollingWindows.computeIfPresent(userName, (key, window) -> {
Review Comment:
`compute`
Add some comments to show the lock.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]