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


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/TarContainerPacker.java:
##########
@@ -289,4 +305,40 @@ OutputStream compress(OutputStream output)
         .createCompressorOutputStream(compression, output);
   }
 
+  private byte[] innerUnpack(InputStream input, Path dbRoot, Path chunksRoot)
+      throws IOException {
+    byte[] descriptorFileContent = null;
+    try (InputStream decompressed = decompress(input);
+         ArchiveInputStream archiveInput = untar(decompressed)) {
+      ArchiveEntry entry = archiveInput.getNextEntry();
+      while (entry != null) {
+        String name = entry.getName();
+        long size = entry.getSize();
+        if (name.startsWith(DB_DIR_NAME + "/")) {
+          Path destinationPath = dbRoot
+              .resolve(name.substring(DB_DIR_NAME.length() + 1));
+          extractEntry(entry, archiveInput, size, dbRoot,
+              destinationPath);
+        } else if (name.startsWith(CHUNKS_DIR_NAME + "/")) {
+          Path destinationPath = chunksRoot
+              .resolve(name.substring(CHUNKS_DIR_NAME.length() + 1));
+          extractEntry(entry, archiveInput, size, chunksRoot,
+              destinationPath);
+        } else if (CONTAINER_FILE_NAME.equals(name)) {
+          //Don't do anything. Container file should be unpacked in a
+          //separated step by unpackContainerDescriptor call.
+          descriptorFileContent = readEntry(archiveInput, size);
+        } else {
+          throw new IllegalArgumentException(
+              "Unknown entry in the tar file: " + "" + name);
+        }
+        entry = archiveInput.getNextEntry();
+      }
+      return descriptorFileContent;
+
+    } catch (CompressorException e) {
+      throw new IOException("Can't uncompress to dbRoot: " + dbRoot +
+              ", chunksRoot: " + chunksRoot, e);
+    }

Review Comment:
   The delete of dest directory is updated in 
KeyValueContainer#importContainerData(InputStream, 
ContainerPacker<KeyValueContainerData>). 
   The delete of tar file is under 
DownloadAndImportReplicator#importContainer(long, Path, HddsVolume) 



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