Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.ozone.OzoneConsts;
Expand All @@ -52,6 +54,9 @@
public class TarContainerPacker
implements ContainerPacker<KeyValueContainerData> {

private static final Logger LOG =
LoggerFactory.getLogger(TarContainerPacker.class);

static final String CHUNKS_DIR_NAME = OzoneConsts.STORAGE_DIR_CHUNKS;

static final String DB_DIR_NAME = "db";
Expand Down Expand Up @@ -152,6 +157,20 @@ public void pack(Container<KeyValueContainerData> container,
try (OutputStream compressed = compress(output);
ArchiveOutputStream archiveOutput = tar(compressed)) {

if (!containerData.getDbFile().exists()) {
LOG.warn("DBfile {} not exist",
containerData.getDbFile().toPath().toString());
return;
} else if (!new File(containerData.getChunksPath()).exists()) {
LOG.warn("Chunkfile {} not exist",
containerData.getDbFile().toPath().toString());
return;
} else if (!container.getContainerFile().exists()) {
LOG.warn("Containerfile {} not exist",
containerData.getDbFile().toPath().toString());
return;
}
Comment on lines +160 to +172
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to utilize Container.scanMetadata() instead? More complete checks without introducing duplication.

Ok,I will change it.thank you very much!

This comment from the previous PR still applies.


includePath(containerData.getDbFile().toPath(), DB_DIR_NAME,
archiveOutput);

Expand Down Expand Up @@ -220,6 +239,9 @@ private void includePath(Path dir, String subdir,
static void includeFile(File file, String entryName,
ArchiveOutputStream archiveOutput) throws IOException {
ArchiveEntry entry = archiveOutput.createArchiveEntry(file, entryName);
if (entry.getSize() == 0) {
return;
}
archiveOutput.putArchiveEntry(entry);
try (InputStream input = new FileInputStream(file)) {
IOUtils.copy(input, archiveOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ public void replicate(ReplicationTask task) {
containerID, bytes);
task.setTransferredBytes(bytes);

importContainer(containerID, path);
if (bytes <= 0) {
task.setStatus(Status.FAILED);
LOG.warn("Container {} is downloaded with size {}",
containerID, bytes);
} else {
importContainer(containerID, path);
LOG.info("Container {} is replicated successfully", containerID);
task.setStatus(Status.DONE);
}
LOG.info("Container {} is replicated successfully", containerID);
task.setStatus(Status.DONE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would overwrite previous FAILED status.

} catch (Exception e) {
Expand Down