anuragp010 commented on code in PR #11965:
URL: https://github.com/apache/ozone/pull/11965#discussion_r4535209618
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/diskbalancer/TestDiskBalancerTask.java:
##########
@@ -285,6 +292,93 @@ public void cleanup() throws IOException {
DiskBalancerService.setInjector(null);
}
+ @ParameterizedTest
+ @CsvSource({"SSD, DISK", "DISK, SSD", "SSD, ARCHIVE", "ARCHIVE, SSD", "DISK,
ARCHIVE", "ARCHIVE, DISK"})
+ public void testCustomPolicyCannotMoveAcrossStorageTypes(StorageType
sourceType, StorageType destinationType)
+ throws IOException {
+ // Keep the real volumes and container files, overriding only their
configured type labels.
+ sourceVolume = spy(sourceVolume);
+ destVolume = spy(destVolume);
+ doReturn(sourceType).when(sourceVolume).getStorageType();
+ doReturn(destinationType).when(destVolume).getStorageType();
+ Container container = createContainer(CONTAINER_ID, sourceVolume,
State.CLOSED);
+ ContainerController controller = spy(ozoneContainer.getController());
+ when(ozoneContainer.getController()).thenReturn(controller);
+ byte[] originalYaml =
Files.readAllBytes(container.getContainerFile().toPath());
+ long sourceUsed = sourceVolume.getCurrentUsage().getUsedSpace();
+ long destUsed = destVolume.getCurrentUsage().getUsedSpace();
+ // Existing reservations and deltas must survive rejection of this
particular move.
+ destVolume.incCommittedBytes(42L);
+ long destCommitted = destVolume.getCommittedBytes();
+ diskBalancerService.getDeltaSizes().put(sourceVolume, 17L);
+ setCustomPolicyCandidate(container);
+
+ DiskBalancerService.DiskBalancerTask task = getTask();
+ assertNotNull(task);
+ assertEquals(destCommitted + CONTAINER_SIZE,
destVolume.getCommittedBytes());
+ assertEquals(17L - CONTAINER_SIZE,
diskBalancerService.getDeltaSizes().get(sourceVolume));
+
assertTrue(diskBalancerService.getInProgressContainers().contains(ContainerID.valueOf(CONTAINER_ID)));
+ task.call();
+
+ verify(controller, never()).copyContainer(any(), any());
+ assertSame(container, containerSet.getContainer(CONTAINER_ID));
+ assertSame(sourceVolume, container.getContainerData().getVolume());
+ assertEquals(State.CLOSED, container.getContainerState());
+ assertArrayEquals(originalYaml,
Files.readAllBytes(container.getContainerFile().toPath()));
+
assertFalse(Files.exists(destVolume.getTmpDir().toPath().resolve(DISK_BALANCER_DIR)
+ .resolve(String.valueOf(CONTAINER_ID))));
+ assertFalse(destVolume.getContainerIterator().hasNext());
+ assertEquals(sourceUsed, sourceVolume.getCurrentUsage().getUsedSpace());
+ assertEquals(destUsed, destVolume.getCurrentUsage().getUsedSpace());
+ assertEquals(destCommitted, destVolume.getCommittedBytes());
+ assertEquals(17L, diskBalancerService.getDeltaSizes().get(sourceVolume));
+
assertFalse(diskBalancerService.getInProgressContainers().contains(ContainerID.valueOf(CONTAINER_ID)));
+ assertEquals(1, diskBalancerService.getMetrics().getFailureCount());
+ assertEquals(0, diskBalancerService.getMetrics().getSuccessCount());
+ assertEquals(0, diskBalancerService.getMetrics().getSuccessBytes());
+ }
+
+ @ParameterizedTest
+ @EnumSource(names = {"DISK", "SSD", "ARCHIVE"})
+ public void
testCustomPolicySameTypeMovePreservesDifferentRecordedType(StorageType
volumeType) throws IOException {
Review Comment:
Nit: Can we add a comment here on what this test protects? From my
understanding, this test covers a relabelled volume where a replica records a
type that differs from it's volume's type.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -544,6 +544,11 @@ public BackgroundTaskResult call() {
LOG.warn("Container {} is in {} state, skipping move process.",
containerId, containerState);
return BackgroundTaskResult.EmptyTaskResult.newResult();
}
+ if (sourceVolume.getStorageType() != destVolume.getStorageType()) {
+ LOG.warn("Skipping disk balancing move for container {} from storage
type {} to {}",
Review Comment:
Nit: Can we modify this to mention why we are skipping the move? For example:
`LOG.warn("Container {}: Source Volume's StorageType ({}) != Destination
Volume's StorageType ({}). Skipping the disk balancing move.", containerId,
sourceVolume.getStorageType(), destVolume.getStorageType());`
--
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]