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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServletInodeBasedXfer.java:
##########
@@ -151,27 +147,43 @@ public void 
processMetadataSnapshotRequest(HttpServletRequest request, HttpServl
         OZONE_DB_CHECKPOINT_REQUEST_TO_EXCLUDE_SST);
     Set<String> receivedSstFiles = extractFilesToExclude(sstParam);
     Path tmpdir = null;
+    OMDBArchiver omdbArchiver = new OMDBArchiver();
+    boolean filesCollected = false;
     try (UncheckedAutoCloseable lock = 
getBootstrapStateLock().acquireWriteLock()) {
       tmpdir = Files.createTempDirectory(getBootstrapTempData().toPath(),
           "bootstrap-data-");
       if (tmpdir == null) {
         throw new IOException("tmp dir is null");
       }
+      omdbArchiver.setTmpDir(tmpdir);
       String tarName = "om.data-" + System.currentTimeMillis() + ".tar";
       response.setContentType("application/x-tar");
       response.setHeader("Content-Disposition", "attachment; filename=\"" + 
tarName + "\"");
       Instant start = Instant.now();
-      writeDbDataToStream(request, response.getOutputStream(), 
receivedSstFiles, tmpdir);
+      collectDbDataToTransfer(request, receivedSstFiles, omdbArchiver);
       Instant end = Instant.now();
       long duration = Duration.between(start, end).toMillis();
-      LOG.info("Time taken to write the checkpoint to response output " +
-          "stream: {} milliseconds", duration);
+      LOG.info("Time taken to collect the DB data : {} milliseconds", 
duration);
       logSstFileList(receivedSstFiles,
           "Excluded {} SST files from the latest checkpoint{}: {}", 5);
+      filesCollected = true;
     } catch (Exception e) {
       LOG.error(
           "Unable to process metadata snapshot request. ", e);
       response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+    }
+    try {
+      if (filesCollected) {
+        Instant start = Instant.now();
+        OutputStream outputStream = response.getOutputStream();
+        omdbArchiver.writeToArchive(getConf(), outputStream);
+        Instant end = Instant.now();
+        long duration = Duration.between(start, end).toMillis();
+        LOG.info("Time taken to write the checkpoint to response output " +
+            "stream: {} milliseconds", duration);
+      }
+    } catch (IOException e) {
+      LOG.error("unable to write to archive stream", e);
     } finally {

Review Comment:
   IIUC we should return 500 here as well? Other than that we can merge it and 
address remaining issues later
   
   ```suggestion
       } catch (IOException e) {
         LOG.error("unable to write to archive stream", e);
         response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
   } finally {
   ```



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