-
Notifications
You must be signed in to change notification settings - Fork 599
HDDS-15135. Import container to another volume if already exists in selected one #10161
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -90,10 +90,12 @@ | |
| import org.apache.hadoop.ozone.container.common.volume.StorageVolume; | ||
| import org.apache.hadoop.ozone.container.common.volume.VolumeSet; | ||
| import org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils; | ||
| import org.apache.hadoop.ozone.container.keyvalue.helpers.KeyValueContainerLocationUtil; | ||
| import org.apache.hadoop.ozone.container.keyvalue.helpers.KeyValueContainerUtil; | ||
| import org.apache.hadoop.ozone.container.metadata.AbstractDatanodeStore; | ||
| import org.apache.hadoop.ozone.container.metadata.DatanodeStore; | ||
| import org.apache.hadoop.ozone.container.replication.CopyContainerCompression; | ||
| import org.apache.hadoop.ozone.container.upgrade.VersionedDatanodeFeatures; | ||
| import org.apache.hadoop.util.DiskChecker; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
@@ -260,6 +262,43 @@ protected void createContainerMetaData(File containerMetaDataPath, | |
| assertEquals(2, callCount.get()); | ||
| } | ||
|
|
||
|
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. Suggestion - DO you think the test coverage should verify non-retriable failures are not retried The PR explicitly says retry is scoped only to CONTAINER_ALREADY_EXISTS. That behavior should have a test. For example, mock controller.importContainer(...) to throw a normal IOException or a StorageContainerException with a different result code. Then verify only the initially selected volume was attempted.
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. @ArafatKhan2198 this comment doesn't hold right in this test class. We do mock |
||
| @ContainerTestVersionInfo.ContainerTest | ||
| public void testNextVolumeTriedWhenSelectedVolumeHasContainerDir( | ||
| ContainerTestVersionInfo versionInfo) throws Exception { | ||
| init(versionInfo); | ||
| String volumeDirPath = | ||
| Files.createDirectory(folder.toPath().resolve("volumeDir")) | ||
| .toFile().getAbsolutePath(); | ||
| HddsVolume newVolume = new HddsVolume.Builder(volumeDirPath) | ||
| .conf(CONF).datanodeUuid(datanodeId.toString()).build(); | ||
| StorageVolumeUtil.checkVolume(newVolume, scmId, scmId, CONF, null, null); | ||
| hddsVolumes.add(newVolume); | ||
| reset(volumeChoosingPolicy); | ||
| when(volumeChoosingPolicy.chooseVolume(anyList(), anyLong())) | ||
| .thenAnswer(invocation -> { | ||
| List<HddsVolume> volumes = invocation.getArgument(0); | ||
| long spaceToReserve = invocation.getArgument(1); | ||
| HddsVolume volume = volumes.get(0); | ||
| volume.incCommittedBytes(spaceToReserve); | ||
| return volume; | ||
| }); | ||
|
|
||
| HddsVolume firstVolume = hddsVolumes.get(0); | ||
| long initialCommittedBytes = firstVolume.getCommittedBytes(); | ||
| String idDir = VersionedDatanodeFeatures.ScmHA.chooseContainerPathID( | ||
| firstVolume, scmId); | ||
| File staleContainerDir = new File(KeyValueContainerLocationUtil | ||
| .getBaseContainerLocation(firstVolume.getHddsRootDir().toString(), | ||
| idDir, keyValueContainerData.getContainerID())); | ||
| assertTrue(staleContainerDir.mkdirs()); | ||
|
|
||
| keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId); | ||
|
|
||
| assertEquals(initialCommittedBytes, firstVolume.getCommittedBytes()); | ||
| assertEquals(newVolume, keyValueContainer.getContainerData().getVolume()); | ||
| assertTrue(staleContainerDir.exists()); | ||
| } | ||
|
|
||
| @ContainerTestVersionInfo.ContainerTest | ||
| public void testEmptyContainerImportExport( | ||
| ContainerTestVersionInfo versionInfo) throws Exception { | ||
|
|
@@ -610,7 +649,8 @@ public void testDuplicateContainer(ContainerTestVersionInfo versionInfo) throws | |
| StorageContainerException exception = assertThrows(StorageContainerException.class, () -> | ||
| keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId)); | ||
| assertEquals(ContainerProtos.Result.CONTAINER_ALREADY_EXISTS, exception.getResult()); | ||
| assertThat(exception).hasMessage("Container creation failed because ContainerFile already exists"); | ||
| assertThat(exception).hasMessage( | ||
| "Container creation failed because ContainerFile already exists on all candidate volumes"); | ||
| } | ||
|
|
||
| @ContainerTestVersionInfo.ContainerTest | ||
|
|
||
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.
We can add JavaDoc to clarify committed-space ownership.
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.
done