ChenSammi commented on code in PR #3648:
URL: https://github.com/apache/ozone/pull/3648#discussion_r1064263073


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/DownloadAndImportReplicator.java:
##########
@@ -105,26 +141,45 @@ public void replicate(ReplicationTask task) {
     LOG.info("Starting replication of container {} from {}", containerID,
         sourceDatanodes);
 
-    // Wait for the download. This thread pool is limiting the parallel
-    // downloads, so it's ok to block here and wait for the full download.
-    Path path =
-        downloader.getContainerDataFromReplicas(containerID, sourceDatanodes);
-    if (path == null) {
-      task.setStatus(Status.FAILED);
-    } else {
-      try {
-        long bytes = Files.size(path);
-        LOG.info("Container {} is downloaded with size {}, starting to 
import.",
-                containerID, bytes);
-        task.setTransferredBytes(bytes);
-
-        importContainer(containerID, path);
-        LOG.info("Container {} is replicated successfully", containerID);
-        task.setStatus(Status.DONE);
-      } catch (IOException e) {
-        LOG.error("Container {} replication was unsuccessful.", containerID, 
e);
+    try {
+      HddsVolume targetVolume = chooseNextVolume();
+      // Wait for the download. This thread pool is limiting the parallel
+      // downloads, so it's ok to block here and wait for the full download.
+      Path tarFilePath =
+          downloader.getContainerDataFromReplicas(containerID, sourceDatanodes,
+              getUntarDirectory(targetVolume));
+      if (tarFilePath == null) {
         task.setStatus(Status.FAILED);
+        return;
       }
+      long bytes = Files.size(tarFilePath);
+      LOG.info("Container {} is downloaded with size {}, starting to import.",
+              containerID, bytes);
+      task.setTransferredBytes(bytes);
+
+      importContainer(containerID, tarFilePath, targetVolume);
+
+      LOG.info("Container {} is replicated successfully", containerID);
+      task.setStatus(Status.DONE);
+    } catch (IOException e) {
+      LOG.error("Container {} replication was unsuccessful.", containerID, e);
+      task.setStatus(Status.FAILED);
     }
   }
+
+  private HddsVolume chooseNextVolume() throws IOException {
+    return volumeChoosingPolicy.chooseVolume(
+        StorageVolumeUtil.getHddsVolumesList(volumeSet.getVolumesList()),
+        containerSize * 2);

Review Comment:
   Can you add a comment here to explain why container * 2 is used? 



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