smengcl commented on code in PR #9324:
URL: https://github.com/apache/ozone/pull/9324#discussion_r2558897684


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/defrag/SnapshotDefragService.java:
##########
@@ -86,24 +124,47 @@ public class SnapshotDefragService extends 
BackgroundService
   private final AtomicLong snapshotsDefraggedCount;
   private final AtomicBoolean running;
 
-  private final MultiSnapshotLocks snapshotIdLocks;
+  private final MultiSnapshotLocks snapshotContentLocks;
   private final OzoneConfiguration conf;
 
   private final BootstrapStateHandler.Lock lock = new 
BootstrapStateHandler.Lock();
+  private final String tmpDefragDir;
+  private final OmSnapshotManager omSnapshotManager;
+  private final OmSnapshotLocalDataManager snapshotLocalDataManager;
+  private final List<UUID> lockIds;
+  private final CompositeDeltaDiffComputer deltaDiffComputer;
+  private final Path differTmpDir;
 
   public SnapshotDefragService(long interval, TimeUnit unit, long 
serviceTimeout,
-      OzoneManager ozoneManager, OzoneConfiguration configuration) {
+      OzoneManager ozoneManager, OzoneConfiguration configuration) throws 
IOException {
     super("SnapshotDefragService", interval, unit, DEFRAG_CORE_POOL_SIZE,
         serviceTimeout, ozoneManager.getThreadNamePrefix());
     this.ozoneManager = ozoneManager;
+    this.omSnapshotManager = ozoneManager.getOmSnapshotManager();
+    this.snapshotLocalDataManager = 
omSnapshotManager.getSnapshotLocalDataManager();
     this.snapshotLimitPerTask = configuration
         .getLong(SNAPSHOT_DEFRAG_LIMIT_PER_TASK,
             SNAPSHOT_DEFRAG_LIMIT_PER_TASK_DEFAULT);
     this.conf = configuration;
     snapshotsDefraggedCount = new AtomicLong(0);
     running = new AtomicBoolean(false);
     IOzoneManagerLock omLock = ozoneManager.getMetadataManager().getLock();
-    this.snapshotIdLocks = new MultiSnapshotLocks(omLock, SNAPSHOT_GC_LOCK, 
true, 1);
+    this.snapshotContentLocks = new MultiSnapshotLocks(omLock, 
SNAPSHOT_DB_CONTENT_LOCK, true, 1);
+    Path tmpDefragDirPath = 
ozoneManager.getMetadataManager().getSnapshotParentDir().toAbsolutePath()
+        .resolve("tmp_defrag");

Review Comment:
   Also, extract this to a const in OzoneConsts instead.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/defrag/SnapshotDefragService.java:
##########
@@ -86,24 +124,47 @@ public class SnapshotDefragService extends 
BackgroundService
   private final AtomicLong snapshotsDefraggedCount;
   private final AtomicBoolean running;
 
-  private final MultiSnapshotLocks snapshotIdLocks;
+  private final MultiSnapshotLocks snapshotContentLocks;
   private final OzoneConfiguration conf;
 
   private final BootstrapStateHandler.Lock lock = new 
BootstrapStateHandler.Lock();
+  private final String tmpDefragDir;
+  private final OmSnapshotManager omSnapshotManager;
+  private final OmSnapshotLocalDataManager snapshotLocalDataManager;
+  private final List<UUID> lockIds;
+  private final CompositeDeltaDiffComputer deltaDiffComputer;
+  private final Path differTmpDir;
 
   public SnapshotDefragService(long interval, TimeUnit unit, long 
serviceTimeout,
-      OzoneManager ozoneManager, OzoneConfiguration configuration) {
+      OzoneManager ozoneManager, OzoneConfiguration configuration) throws 
IOException {
     super("SnapshotDefragService", interval, unit, DEFRAG_CORE_POOL_SIZE,
         serviceTimeout, ozoneManager.getThreadNamePrefix());
     this.ozoneManager = ozoneManager;
+    this.omSnapshotManager = ozoneManager.getOmSnapshotManager();
+    this.snapshotLocalDataManager = 
omSnapshotManager.getSnapshotLocalDataManager();
     this.snapshotLimitPerTask = configuration
         .getLong(SNAPSHOT_DEFRAG_LIMIT_PER_TASK,
             SNAPSHOT_DEFRAG_LIMIT_PER_TASK_DEFAULT);
     this.conf = configuration;
     snapshotsDefraggedCount = new AtomicLong(0);
     running = new AtomicBoolean(false);
     IOzoneManagerLock omLock = ozoneManager.getMetadataManager().getLock();
-    this.snapshotIdLocks = new MultiSnapshotLocks(omLock, SNAPSHOT_GC_LOCK, 
true, 1);
+    this.snapshotContentLocks = new MultiSnapshotLocks(omLock, 
SNAPSHOT_DB_CONTENT_LOCK, true, 1);
+    Path tmpDefragDirPath = 
ozoneManager.getMetadataManager().getSnapshotParentDir().toAbsolutePath()
+        .resolve("tmp_defrag");
+    // Delete and recreate tmp dir if it exists
+    if (tmpDefragDirPath.toFile().exists()) {
+      deleteDirectory(tmpDefragDirPath);
+    }
+    createDirectories(tmpDefragDirPath);
+    this.tmpDefragDir = tmpDefragDirPath.toString();
+    this.differTmpDir = tmpDefragDirPath.resolve("differSstFiles");

Review Comment:
   Same here



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