Skip to content

Commit 06145aa

Browse files
Add comments to AllocateBatch in pkg/ddc/base/portallocator/bitmap_allocator.go (#5800)
* Add comments to AllocateBatch in pkg/ddc/base/portallocator/bitmap_allocator.go Signed-off-by: Caterpillar <w@caterpillar.ink> * Fix issues Signed-off-by: Caterpillar <w@caterpillar.ink> --------- Signed-off-by: Caterpillar <w@caterpillar.ink>
1 parent c6d1c22 commit 06145aa

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pkg/ddc/base/portallocator/bitmap_allocator.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ func (b *BitMapAllocator) Release(port int) error {
6262
return b.alloc.Release(port)
6363
}
6464

65+
// AllocateBatch allocates a batch of ports from the bitmap allocator.
66+
// This function attempts to allocate the specified number of ports and returns them as a slice.
67+
// If allocation fails for any reason (e.g., insufficient available ports), it will rollback all
68+
// previously allocated ports in this batch and exit the process with status code 1 to ensure
69+
// port allocation state consistency.
70+
//
71+
// Parameters:
72+
// - portNum (int): The number of ports to allocate.
73+
//
74+
// Returns:
75+
// - ports ([]int): A slice containing the allocated port numbers.
76+
// - err (error): Always nil if the function returns (note: function exits process on failure)
6577
func (b *BitMapAllocator) AllocateBatch(portNum int) (ports []int, err error) {
6678
var availPort int
6779

0 commit comments

Comments
 (0)