-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-5149 when source datanode download container tar from target datanode,but the target datanode container file missing,import error #2196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
528d3ff
5a7b10d
9ced084
bdb959f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,10 +121,17 @@ public void replicate(ReplicationTask task) { | |
| LOG.info("Container {} is downloaded with size {}, starting to import.", | ||
| containerID, bytes); | ||
| task.setTransferredBytes(bytes); | ||
|
|
||
| importContainer(containerID, path); | ||
| LOG.info("Container {} is replicated successfully", containerID); | ||
| task.setStatus(Status.DONE); | ||
| // if tar is null, the tar size is 45 bytes | ||
| if (bytes <= 45) { | ||
| task.setStatus(Status.FAILED); | ||
| LOG.warn("Container {} is downloaded with size {}, " + | ||
| "if size less than 45 bytes the tar file is null", | ||
| containerID, bytes); | ||
|
Comment on lines
+124
to
+129
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these kind of tar-specific details should be handled by
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hello,I think it should be check in the DownloadAndImportReplicator,because of the source datanode will through outputstream to the tar,if tar is null,the task status should be set failed,the tar size check in TarContainerPacker I think is not useful.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please consider the case if someone wanted to introduce a new implementation of |
||
| } else { | ||
| importContainer(containerID, path); | ||
| LOG.info("Container {} is replicated successfully", containerID); | ||
| task.setStatus(Status.DONE); | ||
| } | ||
| } catch (Exception e) { | ||
| LOG.error("Container {} replication was unsuccessful.", containerID, e); | ||
| task.setStatus(Status.FAILED); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ | |
| import java.io.FileOutputStream; | ||
| import java.io.IOException; | ||
| import java.io.OutputStream; | ||
| import java.nio.file.Files; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.List; | ||
|
|
@@ -238,6 +239,55 @@ public void testContainerImportExport() throws Exception { | |
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testContainerMissingFileImportExport() throws Exception { | ||
| long containerId = keyValueContainer.getContainerData().getContainerID(); | ||
| createContainer(); | ||
| long numberOfKeysToWrite = 12; | ||
| closeContainer(); | ||
| populate(numberOfKeysToWrite); | ||
|
|
||
| //destination path | ||
| File folderToExport = folder.newFile("exported.tar.gz"); | ||
| TarContainerPacker packer = new TarContainerPacker(); | ||
|
|
||
| //if missing chunksfile | ||
| File chunkfile = new File(keyValueContainer. | ||
| getContainerData().getChunksPath()); | ||
| Files.delete(chunkfile.toPath()); | ||
| Assert.assertFalse(chunkfile.exists()); | ||
| //export the container | ||
| try (FileOutputStream fos = new FileOutputStream(folderToExport)) { | ||
| keyValueContainer | ||
| .exportContainerData(fos, packer); | ||
| } | ||
|
|
||
| //delete the original one | ||
| keyValueContainer.delete(); | ||
|
|
||
| //create a new one | ||
| KeyValueContainerData containerData = | ||
| new KeyValueContainerData(containerId, | ||
| keyValueContainerData.getLayOutVersion(), | ||
| keyValueContainerData.getMaxSize(), UUID.randomUUID().toString(), | ||
| datanodeId.toString()); | ||
| KeyValueContainer container = new KeyValueContainer(containerData, CONF); | ||
|
|
||
| HddsVolume containerVolume = volumeChoosingPolicy.chooseVolume(volumeSet | ||
| .getVolumesList(), 1); | ||
| String hddsVolumeDir = containerVolume.getHddsRootDir().toString(); | ||
|
|
||
| container.populatePathFields(scmId, containerVolume, hddsVolumeDir); | ||
| long bytes = Files.size(folderToExport.toPath()); | ||
| Assert.assertTrue(bytes <= 45); | ||
|
|
||
| try (FileInputStream fis = new FileInputStream(folderToExport)) { | ||
| container.importContainerData(fis, packer); | ||
| } catch (Exception ex) { | ||
| assertTrue(ex instanceof NullPointerException); | ||
|
Comment on lines
+285
to
+287
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Create the container on disk. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok,I will change it.thank you very much!