ashishkumar50 commented on code in PR #10000:
URL: https://github.com/apache/ozone/pull/10000#discussion_r3187594757
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/PendingContainerTracker.java:
##########
@@ -189,6 +190,47 @@ public boolean
hasEffectiveAllocatableSpaceForNewContainer(DatanodeInfo datanode
return false;
}
+ /**
+ * Atomically checks if the datanode has space for a new container and
records the allocation
+ * if space is available. This prevents race conditions where multiple
threads check space
+ * concurrently and over-allocate.
+ *
+ * @param datanodeInfo storage reports for the datanode
+ * @param containerID The container being allocated
+ * @return true if space was available and allocation was recorded, false
otherwise
+ */
+ public boolean checkSpaceAndRecordAllocation(DatanodeInfo datanodeInfo,
ContainerID containerID) {
+ Objects.requireNonNull(datanodeInfo, "datanodeInfo == null");
+ Objects.requireNonNull(containerID, "containerID == null");
+
+ TwoWindowBucket bucket = datanodeInfo.getPendingContainerAllocations();
+ synchronized (bucket) {
Review Comment:
Moved to TwoWindowBucket.
--
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]