ChenSammi commented on code in PR #3648:
URL: https://github.com/apache/ozone/pull/3648#discussion_r1066571304
##########
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:
There are three file/directories are involved.
1). downloaded tar file, which is deleted in
DownloadAndImportReplicator#importContainer
2) source untared container directory under "tmp", which should be deleted
in case that it cannot renamed to the target untared container directory in
case target untared container directory already exists. This one is missing.
3) target untared container directory, which will be deleted in
KeyValueContainer#importContainerData if container already exists.
--
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]