GeorgeJahad commented on code in PR #5104:
URL: https://github.com/apache/ozone/pull/5104#discussion_r1271553514


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServlet.java:
##########
@@ -175,23 +188,94 @@ public static Set<Path> normalizeExcludeList(List<String> 
toExcludeList,
     return paths;
   }
 
+  @Override
+  // Pauses rocksdb compaction threads while creating copies of
+  // compaction logs and hard links of sst backups.
+  public DBCheckpoint getCheckpoint(Path tmpdir, boolean flush)
+      throws IOException {
+    DBCheckpoint checkpoint;
+
+    // make tmp directories to contain the copies
+    RocksDBCheckpointDiffer differ = getDbStore().getRocksDBCheckpointDiffer();
+    DirectoryData sstBackupDir = new DirectoryData(tmpdir,
+        differ.getSSTBackupDir());
+    DirectoryData compactionLogDir = new DirectoryData(tmpdir,
+        differ.getCompactionLogDir());
+    if (!sstBackupDir.getTmpDir().mkdirs()) {
+      throw new IOException("mkdirs failed: " + sstBackupDir.getTmpDir());
+    }
+    if (!compactionLogDir.getTmpDir().mkdirs()) {
+      throw new IOException("mkdirs failed: " + compactionLogDir.getTmpDir());
+    }
+
+    long startTime = System.currentTimeMillis();
+    long pauseCounter = PAUSE_COUNTER.incrementAndGet();
+
+    // Pause compactions, Copy/link files and get checkpoint.
+    try {
+      LOG.info("Compaction pausing {} started.", pauseCounter);
+      differ.incrementTarballRequestCount();
+      FileUtils.copyDirectory(compactionLogDir.getDir(),
+          compactionLogDir.getTmpDir());
+      OmSnapshotUtils.linkFiles(sstBackupDir.getDir(),
+          sstBackupDir.getTmpDir());
+      checkpoint = getDbStore().getCheckpoint(flush);
+    } finally {
+      // Unpause the compaction threads.
+      synchronized (getDbStore().getRocksDBCheckpointDiffer()) {
+        differ.decrementTarballRequestCount();
+        differ.notifyAll();
+        long elapsedTime = System.currentTimeMillis() - startTime;
+        LOG.info("Compaction pausing {} ended. Elapsed ms: {}",
+            pauseCounter, elapsedTime);
+      }
+    }
+
+    return checkpoint;
+  }
+
+
+  // Convenience class for keeping track of the tmp dir's.
+  private static class DirectoryData {
+    private final File dir;

Review Comment:
   done



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServlet.java:
##########
@@ -175,23 +188,94 @@ public static Set<Path> normalizeExcludeList(List<String> 
toExcludeList,
     return paths;
   }
 
+  @Override
+  // Pauses rocksdb compaction threads while creating copies of
+  // compaction logs and hard links of sst backups.
+  public DBCheckpoint getCheckpoint(Path tmpdir, boolean flush)
+      throws IOException {
+    DBCheckpoint checkpoint;
+
+    // make tmp directories to contain the copies
+    RocksDBCheckpointDiffer differ = getDbStore().getRocksDBCheckpointDiffer();
+    DirectoryData sstBackupDir = new DirectoryData(tmpdir,
+        differ.getSSTBackupDir());
+    DirectoryData compactionLogDir = new DirectoryData(tmpdir,
+        differ.getCompactionLogDir());
+    if (!sstBackupDir.getTmpDir().mkdirs()) {
+      throw new IOException("mkdirs failed: " + sstBackupDir.getTmpDir());
+    }

Review Comment:
   done



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