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


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -212,7 +234,7 @@ private void processFSOKeys(Set<Long> containerIds, 
Map<Long, List<String>> cont
         if (!keyContainers.isEmpty()) {
           // For FSO keys, reconstruct the full path
           // Or extract just the key name if onlyFileNames is true
-          String keyPath = onlyFileNames ? keyInfo.getKeyName() :
+          String keyPath = onlyFileNames ? "[fso] " + keyInfo.getKeyName() :

Review Comment:
   do not add specific tag for keyname or filename or others. Let it come as it 
is.



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -251,6 +273,123 @@ private void processOBSKeys(Set<Long> containerIds, 
Map<Long, List<String>> cont
     }
   }
 
+  private void processOpenFiles(Set<Long> containerIds, Map<Long, 
List<String>> containerToOpenKeysMap,
+      Map<Long, Long> unreferencedCountMap, Map<Long, Pair<Long, String>> 
bucketVolMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
fileIterator =
+             openFileTable.iterator()) {
+      while (fileIterator.hasNext()) {
+        OmKeyInfo keyInfo = fileIterator.next().getValue();
+        addOpenKeyToContainerMap(keyInfo, containerIds, 
containerToOpenKeysMap, true,
+            bucketVolMap, unreferencedCountMap);
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openFileTable (FSO keys), " + 
e);
+    }
+  }
+
+  private void processOpenKeys(Set<Long> containerIds, Map<Long, List<String>> 
containerToOpenKeysMap) {
+    try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> 
keyIterator =
+             openKeyTable.iterator()) {
+      while (keyIterator.hasNext()) {
+        OmKeyInfo keyInfo = keyIterator.next().getValue();
+        addOpenKeyToContainerMap(keyInfo, containerIds, 
containerToOpenKeysMap, false, null, null);
+      }
+    } catch (Exception e) {
+      err().println("Exception occurred reading openKeyTable (OBS keys), " + 
e);
+    }
+  }
+
+  private void addOpenKeyToContainerMap(OmKeyInfo keyInfo, Set<Long> 
containerIds,
+      Map<Long, List<String>> containerToOpenKeysMap, boolean isFSO,
+      Map<Long, Pair<Long, String>> bucketVolMap, Map<Long, Long> 
unreferencedCountMap) throws Exception {
+    // 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;
+      if (onlyFileNames) {
+        String bucketType = isFSO ? "fso" : "obs";
+        String prefix = isMpuKey ? "[mpu-" + bucketType + "] " : "[" + 
bucketType + "] ";
+        keyPath = prefix + keyInfo.getKeyName();
+      } else {
+        if (isFSO) {
+          keyPath = reconstructFullPath(keyInfo, bucketVolMap, 
unreferencedCountMap, keyContainers);
+          if (keyPath != null && isMpuKey) {
+            keyPath = "[mpu] " + keyPath;
+          }
+        } else {
+          String prefix = isMpuKey ? "[mpu] " : "";
+          keyPath = prefix + buildFullOBSPath(keyInfo);
+        }
+      }
+
+      if (keyPath != null) {
+        for (Long containerId : keyContainers) {
+          containerToOpenKeysMap.get(containerId).add(keyPath);
+        }
+      }
+    }
+  }
+
+  private void processMultipartUpload(Set<Long> containerIds, Map<Long, 
List<String>> containerToOpenKeysMap,
+      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 + "] ";

Review Comment:
   avoid add tag, if required, can break open keys to mpu, and others



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