sreejasahithi commented on code in PR #9703:
URL: https://github.com/apache/ozone/pull/9703#discussion_r2759647856


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -251,6 +273,135 @@ private void processOBSKeys(Set<Long> containerIds, 
Map<Long, List<String>> cont
     }
   }
 
+  private void processOpenFiles(Set<Long> containerIds, Map<Long, 
List<String>> containerToKeysMap,
+      Map<Long, Long> unreferencedCountMap, Map<Long, Pair<Long, String>> 
bucketVolMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
fileIterator =
+             openFileTable.iterator()) {
+      while (fileIterator.hasNext()) {
+        Table.KeyValue<String, OmKeyInfo> entry = fileIterator.next();
+        OmKeyInfo keyInfo = entry.getValue();
+
+        // Find which containers this key uses
+        Set<Long> keyContainers = getKeyContainers(keyInfo, containerIds);
+
+        if (!keyContainers.isEmpty()) {
+          OmKeyLocationInfoGroup locations = 
keyInfo.getLatestVersionLocations();
+          boolean isMpuKey = locations != null && locations.isMultipartKey();
+
+          String keyPath;
+          String prefix;
+          if (onlyFileNames) {
+            prefix = isMpuKey ? "[mpu-fso] " : "[fso] ";
+            keyPath = prefix + keyInfo.getKeyName();
+          } else {
+            keyPath = reconstructFullPath(keyInfo, bucketVolMap, 
unreferencedCountMap, keyContainers);
+            if (keyPath != null) {
+              prefix = isMpuKey ? "[mpu] " : "";
+              keyPath = prefix + keyPath;
+            }
+          }
+
+          if (keyPath != null) {
+            for (Long containerId : keyContainers) {
+              containerToKeysMap.get(containerId).add(keyPath);
+            }
+          }
+        }
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openFileTable (FSO keys), " + 
e);
+    }
+  }
+
+  private void processOpenKeys(Set<Long> containerIds, Map<Long, List<String>> 
containerToKeysMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
keyIterator =
+             openKeyTable.iterator()) {
+      while (keyIterator.hasNext()) {
+        OmKeyInfo keyInfo = keyIterator.next().getValue();
+
+        // Find which containers this key uses
+        Set<Long> keyContainers = getKeyContainers(keyInfo, containerIds);
+
+        if (!keyContainers.isEmpty()) {
+          OmKeyLocationInfoGroup locations = 
keyInfo.getLatestVersionLocations();
+          boolean isMpuKey = locations != null && locations.isMultipartKey();
+
+          String keyPath;
+          String prefix;
+          if (onlyFileNames) {
+            prefix = isMpuKey ? "[mpu-obs] " : "[obs] ";
+            keyPath = prefix + keyInfo.getKeyName();
+          } else {
+            prefix = isMpuKey ? "[mpu] " : "";
+            keyPath = prefix + buildFullOBSPath(keyInfo);
+          }
+
+          for (Long containerId : keyContainers) {
+            containerToKeysMap.get(containerId).add(keyPath);
+          }
+        }
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openKeyTable (OBS keys), " + 
e);
+    }
+  }
+
+  private void processMultipartUpload(Set<Long> containerIds, Map<Long, 
List<String>> containerToKeysMap,

Review Comment:
   same here



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -251,6 +273,135 @@ private void processOBSKeys(Set<Long> containerIds, 
Map<Long, List<String>> cont
     }
   }
 
+  private void processOpenFiles(Set<Long> containerIds, Map<Long, 
List<String>> containerToKeysMap,
+      Map<Long, Long> unreferencedCountMap, Map<Long, Pair<Long, String>> 
bucketVolMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
fileIterator =
+             openFileTable.iterator()) {
+      while (fileIterator.hasNext()) {
+        Table.KeyValue<String, OmKeyInfo> entry = fileIterator.next();
+        OmKeyInfo keyInfo = entry.getValue();
+
+        // Find which containers this key uses
+        Set<Long> keyContainers = getKeyContainers(keyInfo, containerIds);
+
+        if (!keyContainers.isEmpty()) {
+          OmKeyLocationInfoGroup locations = 
keyInfo.getLatestVersionLocations();
+          boolean isMpuKey = locations != null && locations.isMultipartKey();
+
+          String keyPath;
+          String prefix;
+          if (onlyFileNames) {
+            prefix = isMpuKey ? "[mpu-fso] " : "[fso] ";
+            keyPath = prefix + keyInfo.getKeyName();
+          } else {
+            keyPath = reconstructFullPath(keyInfo, bucketVolMap, 
unreferencedCountMap, keyContainers);
+            if (keyPath != null) {
+              prefix = isMpuKey ? "[mpu] " : "";
+              keyPath = prefix + keyPath;
+            }
+          }
+
+          if (keyPath != null) {
+            for (Long containerId : keyContainers) {
+              containerToKeysMap.get(containerId).add(keyPath);
+            }
+          }
+        }
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openFileTable (FSO keys), " + 
e);
+    }
+  }
+
+  private void processOpenKeys(Set<Long> containerIds, Map<Long, List<String>> 
containerToKeysMap) {

Review Comment:
   same here



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -251,6 +273,135 @@ private void processOBSKeys(Set<Long> containerIds, 
Map<Long, List<String>> cont
     }
   }
 
+  private void processOpenFiles(Set<Long> containerIds, Map<Long, 
List<String>> containerToKeysMap,
+      Map<Long, Long> unreferencedCountMap, Map<Long, Pair<Long, String>> 
bucketVolMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
fileIterator =
+             openFileTable.iterator()) {
+      while (fileIterator.hasNext()) {
+        Table.KeyValue<String, OmKeyInfo> entry = fileIterator.next();
+        OmKeyInfo keyInfo = entry.getValue();
+
+        // Find which containers this key uses
+        Set<Long> keyContainers = getKeyContainers(keyInfo, containerIds);
+
+        if (!keyContainers.isEmpty()) {
+          OmKeyLocationInfoGroup locations = 
keyInfo.getLatestVersionLocations();
+          boolean isMpuKey = locations != null && locations.isMultipartKey();
+
+          String keyPath;
+          String prefix;
+          if (onlyFileNames) {
+            prefix = isMpuKey ? "[mpu-fso] " : "[fso] ";
+            keyPath = prefix + keyInfo.getKeyName();
+          } else {
+            keyPath = reconstructFullPath(keyInfo, bucketVolMap, 
unreferencedCountMap, keyContainers);
+            if (keyPath != null) {
+              prefix = isMpuKey ? "[mpu] " : "";
+              keyPath = prefix + keyPath;
+            }
+          }
+
+          if (keyPath != null) {
+            for (Long containerId : keyContainers) {
+              containerToKeysMap.get(containerId).add(keyPath);
+            }
+          }
+        }
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openFileTable (FSO keys), " + 
e);
+    }
+  }
+
+  private void processOpenKeys(Set<Long> containerIds, Map<Long, List<String>> 
containerToKeysMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
keyIterator =
+             openKeyTable.iterator()) {
+      while (keyIterator.hasNext()) {
+        OmKeyInfo keyInfo = keyIterator.next().getValue();
+
+        // Find which containers this key uses
+        Set<Long> keyContainers = getKeyContainers(keyInfo, containerIds);
+
+        if (!keyContainers.isEmpty()) {
+          OmKeyLocationInfoGroup locations = 
keyInfo.getLatestVersionLocations();
+          boolean isMpuKey = locations != null && locations.isMultipartKey();
+
+          String keyPath;
+          String prefix;
+          if (onlyFileNames) {
+            prefix = isMpuKey ? "[mpu-obs] " : "[obs] ";
+            keyPath = prefix + keyInfo.getKeyName();
+          } else {
+            prefix = isMpuKey ? "[mpu] " : "";
+            keyPath = prefix + buildFullOBSPath(keyInfo);
+          }
+
+          for (Long containerId : keyContainers) {
+            containerToKeysMap.get(containerId).add(keyPath);
+          }
+        }
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openKeyTable (OBS keys), " + 
e);
+    }
+  }
+
+  private void processMultipartUpload(Set<Long> containerIds, Map<Long, 
List<String>> containerToKeysMap,
+      Map<Long, Long> unreferencedCountMap, Map<Long, Pair<Long, String>> 
bucketVolMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, 
OmMultipartKeyInfo>> mpuIterator =
+             multipartInfoTable.iterator()) {
+
+      while (mpuIterator.hasNext()) {
+        Table.KeyValue<String, OmMultipartKeyInfo> entry = mpuIterator.next();
+        OmMultipartKeyInfo mpuInfo = entry.getValue();
+
+        // Iterate through all uploaded parts
+        for (PartKeyInfo partKeyInfo : mpuInfo.getPartKeyInfoMap()) {
+          OmKeyInfo partKey = 
OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
+          Set<Long> keyContainers = getKeyContainers(partKey, containerIds);
+
+          if (!keyContainers.isEmpty()) {
+            int partNumber = partKeyInfo.getPartNumber();
+            // Check if this is FSO or OBS based on parentObjectID
+            // FSO keys have parentObjectID > 0 pointing to parent directory
+            // OBS keys have parentObjectID = 0
+            boolean isOBS = partKey.getParentObjectID() == 0;
+            String bucketType = isOBS ? "obs" : "fso";
+
+            String keyPath;
+            if (onlyFileNames) {
+              String prefix = "[mpu-part-" + partNumber + "-" + bucketType + 
"] ";
+              keyPath = prefix + partKey.getKeyName();
+            } else {
+              String prefix = "[mpu-part-" + partNumber + "] ";
+              if (isOBS) {
+                keyPath = prefix + buildFullOBSPath(partKey);
+              } else {
+                keyPath = reconstructFullPath(partKey, bucketVolMap, 
unreferencedCountMap, keyContainers);
+                if (keyPath != null) {
+                  keyPath = prefix + keyPath;
+                }
+              }
+            }
+
+            if (keyPath != null) {
+              for (Long containerId : keyContainers) {
+                containerToKeysMap.get(containerId).add(keyPath);
+              }
+            }
+          }
+        }
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openFileTable (FSO keys), " + 
e);

Review Comment:
   Shouldn't this be "Exception occurred reading **multipartInfoTable**"?



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -251,6 +273,135 @@ private void processOBSKeys(Set<Long> containerIds, 
Map<Long, List<String>> cont
     }
   }
 
+  private void processOpenFiles(Set<Long> containerIds, Map<Long, 
List<String>> containerToKeysMap,

Review Comment:
   To this method we are passing containerToOpenKeysMap but the param here is 
containerToKeysMap, this can look confusing, could you please update the name 
of the param to avoid confusion.



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