slfan1989 commented on code in PR #10333:
URL: https://github.com/apache/ozone/pull/10333#discussion_r3294745827
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/diskbalancer/TestDiskBalancerTask.java:
##########
@@ -676,7 +706,106 @@ public void
testMoveSkippedWhenContainerStateChanged(State invalidState)
assertFalse(diskBalancerService.getInProgressContainers().contains(ContainerID.valueOf(CONTAINER_ID)));
// Verify delta sizes are restored
- assertEquals(initialSourceDelta,
diskBalancerService.getDeltaSizes().get(sourceVolume));
+ assertEquals(initialSourceDelta, getDeltaSize(sourceVolume));
+ }
+
+ private DiskBalancerService.DiskBalancerTask newTask(long containerId) {
+ KeyValueContainerData containerData = new KeyValueContainerData(
+ containerId, ContainerLayoutVersion.FILE_PER_BLOCK, CONTAINER_SIZE,
+ UUID.randomUUID().toString(), datanodeUuid);
+ containerData.getStatistics().setBlockBytesForTesting(CONTAINER_SIZE);
+ return diskBalancerService.new DiskBalancerTask(containerData,
+ sourceVolume, destVolume);
+ }
+
+ private void invokePostCall(Method postCall,
+ DiskBalancerService.DiskBalancerTask task) {
+ try {
+ postCall.invoke(task, false, TimeUnit.MILLISECONDS.toMillis(1));
+ } catch (ReflectiveOperationException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ private void setDeltaSizes(Map<HddsVolume, Long> deltaSizes)
+ throws ReflectiveOperationException {
+ Field field = DiskBalancerService.class.getDeclaredField("deltaSizes");
+ field.setAccessible(true);
+ field.set(diskBalancerService, deltaSizes);
+ }
+
+ private long getDeltaSize(HddsVolume volume) {
+ return diskBalancerService.getDeltaSizes().getOrDefault(volume, 0L);
+ }
+
+ private static final class RacingDeltaMap
Review Comment:
Makes sense. I removed the custom concurrency test and its helper changes,
since it does not reproduce the real `ConcurrentHashMap` race. The PR now only
keeps the two atomic `deltaSizes.merge(..., Long::sum)` updates.
--
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]