sumitagrawl commented on code in PR #7934:
URL: https://github.com/apache/ozone/pull/7934#discussion_r1984423421


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/TarContainerPacker.java:
##########
@@ -95,9 +101,19 @@ public byte[] 
unpackContainerData(Container<KeyValueContainerData> container,
       Files.createDirectories(destContainerDir);
     }
     if (FileUtils.isEmptyDirectory(destContainerDir.toFile())) {
+      // Before the atomic move, the destination dir is empty and doesn't have 
a metadata directory.
+      // Writing the .container file will fail as the metadata dir doesn't 
exist
+      Path containerMetadataPath = 
Paths.get(container.getContainerData().getMetadataPath());
+      Path tempContainerMetadataPath = Paths.get(containerUntarDir.toString(),
+          containerMetadataPath.getName(containerMetadataPath.getNameCount() - 
1).toString());
+      
container.getContainerData().setMetadataPath(tempContainerMetadataPath.toString());
+      persistCustomContainerState(container, descriptorFileContent, 
State.RECOVERING);
+      
container.getContainerData().setMetadataPath(containerMetadataPath.toString());
       Files.move(containerUntarDir, destContainerDir,
               StandardCopyOption.ATOMIC_MOVE,
               StandardCopyOption.REPLACE_EXISTING);
+      // Persist again to update the metadata path to point the destination dir
+      persistCustomContainerState(container, descriptorFileContent, 
State.RECOVERING);

Review Comment:
   We need refactor code



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