devmadhuu commented on code in PR #5620:
URL: https://github.com/apache/ozone/pull/5620#discussion_r1412332365


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java:
##########
@@ -100,42 +111,89 @@ public void run() {
 
   public void triggerContainerHealthCheck() {
     lock.writeLock().lock();
+    Map<String, Map<String, Long>> unhealthyContainerStateStatsMap;
     try {
+      unhealthyContainerStateStatsMap = new HashMap<>(Collections.emptyMap());
+      initializeUnhealthyContainerStateStatsMap(
+          unhealthyContainerStateStatsMap);
       long start = Time.monotonicNow();
       long currentTime = System.currentTimeMillis();
-      long existingCount = processExistingDBRecords(currentTime);
+      long existingCount = processExistingDBRecords(currentTime,
+          unhealthyContainerStateStatsMap);
       LOG.info("Container Health task thread took {} milliseconds to" +
               " process {} existing database records.",
           Time.monotonicNow() - start, existingCount);
       start = Time.monotonicNow();
       final List<ContainerInfo> containers = containerManager.getContainers();
       containers.stream()
           .filter(c -> !processedContainers.contains(c))
-          .forEach(c -> processContainer(c, currentTime));
+          .forEach(c -> processContainer(c, currentTime,
+              unhealthyContainerStateStatsMap));
       recordSingleRunCompletion();
       LOG.info("Container Health task thread took {} milliseconds for" +
               " processing {} containers.", Time.monotonicNow() - start,
           containers.size());
+      logUnhealthyContainerStats(unhealthyContainerStateStatsMap);
       processedContainers.clear();
     } finally {
       lock.writeLock().unlock();
     }
   }
 
+  private void logUnhealthyContainerStats(
+      Map<String, Map<String, Long>> unhealthyContainerStateStatsMap) {
+    // If any EMPTY_MISSING containers, then it is possible that such
+    // containers got stuck in the closing state which never got
+    // any replicas created on the datanodes. In this case, we log it as
+    // EMPTY, and insert as EMPTY_MISSING in UNHEALTHY_CONTAINERS table.
+    unhealthyContainerStateStatsMap.entrySet().forEach(stateEntry -> {
+      String unhealthyContainerState = stateEntry.getKey();
+      Map<String, Long> containerStateStatsMap = stateEntry.getValue();
+      StringBuilder logMsgBuilder = new StringBuilder(unhealthyContainerState);

Review Comment:
   Done.



-- 
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]

Reply via email to