sumitagrawl commented on code in PR #8955:
URL: https://github.com/apache/ozone/pull/8955#discussion_r2284136565
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/FSORepairTool.java:
##########
@@ -306,12 +312,55 @@ private void markReachableObjectsInBucket(OmVolumeArgs
volume, OmBucketInfo buck
}
}
- private boolean isDirectoryInDeletedDirTable(String dirKey) throws
IOException {
- return deletedDirectoryTable.isExist(dirKey);
- }
+ private void markUnreachableObjectsInBucket(OmVolumeArgs volume,
OmBucketInfo bucket) throws IOException {
+ // Only put directories in the stack.
+ // Directory keys should have the form /volumeID/bucketID/parentID/name.
+ Stack<String> dirKeyStack = new Stack<>();
+
+ // Find all deleted directories in this bucket and process their children
+ String bucketPrefix = OM_KEY_PREFIX + volume.getObjectID() +
OM_KEY_PREFIX + bucket.getObjectID();
+
+ try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
deletedDirIterator =
+ deletedDirectoryTable.iterator()) {
+ deletedDirIterator.seek(bucketPrefix);
+ while (deletedDirIterator.hasNext()) {
+ Table.KeyValue<String, OmKeyInfo> deletedDirEntry =
deletedDirIterator.next();
+ String deletedDirKey = deletedDirEntry.getKey();
+
+ // Only process deleted directories in this bucket
+ if (!deletedDirKey.startsWith(bucketPrefix)) {
+ break;
+ }
+
+ // Extract the objectID from the deleted directory entry
+ OmKeyInfo deletedDirInfo = deletedDirEntry.getValue();
+ long deletedObjectID = deletedDirInfo.getObjectID();
+
+ // Build the prefix that children would have:
/volID/bucketID/deletedObjectID/
+ String childPrefix = OM_KEY_PREFIX + volume.getObjectID() +
OM_KEY_PREFIX + bucket.getObjectID() +
+ OM_KEY_PREFIX + deletedObjectID + OM_KEY_PREFIX;
+
+ // Find all children of this deleted directory and mark as
unreachable
+ Collection<String> childDirs =
getChildDirectoriesAndMarkAsUnreachable(childPrefix);
+ dirKeyStack.addAll(childDirs);
+ }
+ }
+
+ while (!dirKeyStack.isEmpty()) {
+ // Get one directory and process its immediate children.
+ String currentDirKey = dirKeyStack.pop();
+ OmDirectoryInfo currentDir = directoryTable.get(currentDirKey);
+ if (currentDir == null) {
+ info("Directory key " + currentDirKey + " to be processed was not
found in the directory table.");
Review Comment:
if comming on console, we can avoid logging this, as may be too many
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/FSORepairTool.java:
##########
@@ -170,6 +173,7 @@ public Report run() throws Exception {
volumeIterator = volumeTable.iterator()) {
try {
openReachableDB();
+ openUnreachableDB();
Review Comment:
no need another db, can be reachableDb with another table
--
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]