priyeshkaratha commented on code in PR #9599:
URL: https://github.com/apache/ozone/pull/9599#discussion_r2708652227
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -163,59 +166,102 @@ private void closeDirTreeDB(String dbPath) throws
IOException {
}
}
- private void retrieve(PrintWriter writer, Set<Long> containerIds) {
- // Build dir tree
+ private void retrieve(String dbPath, PrintWriter writer, Set<Long>
containerIds) {
Map<Long, Pair<Long, String>> bucketVolMap = new HashMap<>();
- try {
- prepareDirIdTree(bucketVolMap);
- } catch (Exception e) {
- err().println("Exception occurred reading directory Table, " + e);
- return;
+ // Build dir tree for FSO keys only if we need full paths
+ if (!onlyFileNames) {
+ try {
+ openDirTreeDB(dbPath);
+ prepareDirIdTree(bucketVolMap);
+ } catch (Exception e) {
+ err().println("Exception occurred reading directory Table, " + e);
+ return;
+ }
}
// Map to collect keys per container
Map<Long, List<String>> containerToKeysMap = new HashMap<>();
- // Track unreferenced keys count per container
+ // Track unreferenced keys count per container (FSO only)
Map<Long, Long> unreferencedCountMap = new HashMap<>();
for (Long containerId : containerIds) {
containerToKeysMap.put(containerId, new ArrayList<>());
unreferencedCountMap.put(containerId, 0L);
}
- // Iterate file table and filter for container
- try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
fileIterator =
+ // Process FSO keys (fileTable)
+ processFSOKeys(containerIds, containerToKeysMap, unreferencedCountMap,
bucketVolMap);
+
+ // Process OBS keys (keyTable)
+ processOBSKeys(containerIds, containerToKeysMap);
+
+ jsonOutput(writer, containerToKeysMap, unreferencedCountMap);
+ }
Review Comment:
nit - please remove unnecessary new lines in the code. I can see after
calling every method a new line is added.
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/ContainerToKeyMapping.java:
##########
@@ -80,22 +79,26 @@ public class ContainerToKeyMapping extends
AbstractSubcommand implements Callabl
description = "Comma separated Container IDs")
private String containers;
+ @CommandLine.Option(names = {"--onlyFileNames"},
+ defaultValue = "false",
+ description = "Only display file names without full path")
+ private boolean onlyFileNames;
+
private DBStore omDbStore;
private Table<String, OmVolumeArgs> volumeTable;
private Table<String, OmBucketInfo> bucketTable;
private Table<String, OmDirectoryInfo> directoryTable;
private Table<String, OmKeyInfo> fileTable;
+ private Table<String, OmKeyInfo> keyTable;
private DBStore dirTreeDbStore;
private Table<Long, String> dirTreeTable;
// Cache volume IDs to avoid repeated lookups
private final Map<String, Long> volumeCache = new HashMap<>();
private ConfigurationSource conf;
- // TODO: Add support to OBS keys (HDDS-14118)
@Override
public Void call() throws Exception {
- err().println("Note: A container can have both FSO and OBS keys. Currently
this tool processes only FSO keys");
-
+
Review Comment:
nit - avoid this new line
--
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]