smengcl commented on code in PR #10333:
URL: https://github.com/apache/ozone/pull/10333#discussion_r3293404526
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -492,6 +491,30 @@ private boolean shouldDelay() {
return false;
}
+ private void reserveDeltaSize(HddsVolume sourceVolume, long bytes) {
+ // deltaSizes can be updated by multiple DiskBalancer tasks for the same
+ // source volume. Use compute to avoid lost updates from a non-atomic
+ // get/put sequence.
+ deltaSizes.compute(sourceVolume, (volume, current) -> {
Review Comment:
nit: Comment can be javadoc right above the method
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -492,6 +491,30 @@ private boolean shouldDelay() {
return false;
}
+ private void reserveDeltaSize(HddsVolume sourceVolume, long bytes) {
+ // deltaSizes can be updated by multiple DiskBalancer tasks for the same
+ // source volume. Use compute to avoid lost updates from a non-atomic
+ // get/put sequence.
+ deltaSizes.compute(sourceVolume, (volume, current) -> {
+ long updated = (current == null ? 0L : current) - bytes;
+ return updated == 0L ? null : updated;
+ });
+ }
+
+ private void releaseDeltaSize(HddsVolume sourceVolume, long bytes) {
+ // Match reserveDeltaSize and release the previously reserved bytes
+ // atomically when a DiskBalancer task completes.
Review Comment:
same nit: Comment can be javadoc right above the method
--
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]