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


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -470,14 +473,28 @@ public BackgroundTaskResult call() {
       Path diskBalancerTmpDir = null, diskBalancerDestDir = null;
       long containerSize = containerData.getBytesUsed();
       try {
+        // Step 1: Copy container to new Volume's tmp Dir
         diskBalancerTmpDir = destVolume.getTmpDir().toPath()
             .resolve(DISK_BALANCER_DIR).resolve(String.valueOf(containerId));
-
-        // Copy container to new Volume's tmp Dir
         ozoneContainer.getController().copyContainer(containerData,
             diskBalancerTmpDir);
 
-        // Move container directory to final place on new volume
+        // Step 2: Transition to Temp container to Temp C1-RECOVERING
+        File tempContainerFile = ContainerUtils.getContainerFile(
+            diskBalancerTmpDir.toFile());
+        if (!tempContainerFile.exists()) {
+          throw new IOException("ContainerFile for container " + containerId
+              + " doesn't exist in temp directory "
+              + tempContainerFile.getAbsolutePath());
+        }
+        ContainerData tempContainerData = ContainerDataYaml
+            .readContainerFile(tempContainerFile);
+        
tempContainerData.setState(ContainerProtos.ContainerDataProto.State.RECOVERING);
+
+        // overwrite the .container file with the new state.
+        ContainerDataYaml.createContainerFile(tempContainerData, 
tempContainerFile);
+
+        // Step 3: Move container directory to final place on new volume

Review Comment:
   if (destDirParent != null)  check is incorrect.  Need to check whether 
destDirParent as a directory exists or not.  



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