ArafatKhan2198 commented on code in PR #5841:
URL: https://github.com/apache/ozone/pull/5841#discussion_r1444269244
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java:
##########
@@ -142,9 +158,14 @@ public void triggerContainerHealthCheck() {
" processing {} containers.", Time.monotonicNow() - start,
containers.size());
logUnhealthyContainerStats(unhealthyContainerStateStatsMap);
- processedContainers.clear();
- } finally {
- lock.writeLock().unlock();
+ if (containers.size() > Integer.parseInt(DEFAULT_FETCH_COUNT)) {
+ startID = ContainerID.valueOf(
+ containers.get(containers.size() - 1).getContainerID());
+ containers.clear();
+ containers = containerManager.getContainers(startID,
+ Integer.parseInt(DEFAULT_FETCH_COUNT));
+ }
+ containers.clear();
Review Comment:
The `containers.clear()`; statement inside the loop is meant to clear the
list before fetching the next batch. However, the last `containers.clear();`
statement outside the loop seems redundant since the loop condition `(while
(!containers.isEmpty()))` ensures that it's only executed when containers is
empty.?
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java:
##########
@@ -131,8 +132,23 @@ public void triggerContainerHealthCheck() {
LOG.info("Container Health task thread took {} milliseconds to" +
" process {} existing database records.",
Time.monotonicNow() - start, existingCount);
+
+ checkAndProcessContainers(unhealthyContainerStateStatsMap, currentTime);
+ processedContainers.clear();
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ private void checkAndProcessContainers(
+ Map<UnHealthyContainerStates, Map<String, Long>>
+ unhealthyContainerStateStatsMap, long currentTime) {
+ ContainerID startID = ContainerID.valueOf(1);
+ List<ContainerInfo> containers = containerManager.getContainers(startID,
+ Integer.parseInt(DEFAULT_FETCH_COUNT));
Review Comment:
Could we replace the usage of `Integer.parseInt(DEFAULT_FETCH_COUNT)` with a
named constant or a method as `DEFAULT_FETCH_COUNT` is a constant.
```
private static final int FETCH_COUNT = Integer.parseInt(DEFAULT_FETCH_COUNT);
```
--
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]