Class BufferPoolChunkAllocationTest
java.lang.Object
org.apache.kafka.clients.producer.internals.BufferPoolChunkAllocationTest
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidteardown()voidMulti-chunk request returns ceil(totalSize / chunkSize) chunks.voidSingle-chunk request returns a list of one buffer at the chunk size.voidTotal size that's not a multiple of chunk size rounds upvoidPool memory accounting: after allocation, the unallocated portion shrinks by the request.voidClosing the pool while a multi-chunk request is parked must surface aKafkaExceptionand refund all reserved bytes.voidReturning chunks via deallocate restores pool memory.voidFIFO fairness across the K-chunk request.voidA request that cannot be satisfied immediately and has no time to wait takes nothing: it blocks on the wait queue before acquiring anything, so the timeout leaves pool memory untouched (no roll back needed).voidNo partial chunk holds during the wait.voidvoidvoidA chunk request that must wait for memory and then completes by taking chunks as they are freed must account for those chunks exactly once — as memory now held by the caller — so the pool neither loses nor over-reports capacity.voidA chunk request that can't be satisfied immediately must wait for memory, taking chunks as they are freed.
-
Constructor Details
-
BufferPoolChunkAllocationTest
public BufferPoolChunkAllocationTest()
-
-
Method Details
-
teardown
@AfterEach public void teardown() -
testAllocateOneChunk
-
testAllocateRoundsUpToChunkBoundary
-
testAllocateMultipleChunks
-
testAvailableMemoryAfterAllocation
-
testDeallocationRestoresMemory
-
testRejectsRequestExceedingTotalMemory
@Test public void testRejectsRequestExceedingTotalMemory() -
testRejectsNonPositiveRequest
@Test public void testRejectsNonPositiveRequest() -
testImmediateTimeoutAcquiresNothing
-
testNoPartialHoldsDuringWait
-
testFifoFairnessAcrossMultiChunkAndSingleChunkRequests
FIFO fairness across the K-chunk request. A multi-chunk request that joins the wait queue before a single-chunk request must complete first when memory becomes available — the K-chunk request occupies a single waiter slot, not K of them.- Throws:
Exception
-
testWaitingRequestDoesNotDoubleRefundChunksOnTimeout
A chunk request that can't be satisfied immediately must wait for memory, taking chunks as they are freed. If it then times out before acquiring all it needs, each chunk it already took must be returned to the pool exactly once. A double refund would make the pool over-reportavailableMemory(), letting later allocations exceed the configuredbuffer.memorylimit.- Throws:
Exception
-
testWaitingRequestDoesNotCorruptAccountingOnSuccess
A chunk request that must wait for memory and then completes by taking chunks as they are freed must account for those chunks exactly once — as memory now held by the caller — so the pool neither loses nor over-reports capacity.- Throws:
Exception
-
testCloseDuringAtomicWait
-