public class NetworkBufferPool extends Object implements BufferPoolFactory, MemorySegmentProvider, AvailabilityProvider
MemorySegment
instances for the network
stack.
The NetworkBufferPool creates LocalBufferPool
s from which the individual tasks draw
the buffers for the network data transfer. When new local buffer pools are created, the
NetworkBufferPool dynamically redistributes the buffers between the pools.
AvailabilityProvider.AvailabilityHelper
AVAILABLE
Constructor and Description |
---|
NetworkBufferPool(int numberOfSegmentsToAllocate,
int segmentSize) |
NetworkBufferPool(int numberOfSegmentsToAllocate,
int segmentSize,
java.time.Duration requestSegmentsTimeout)
Allocates all
MemorySegment instances managed by this pool. |
Modifier and Type | Method and Description |
---|---|
int |
countBuffers() |
BufferPool |
createBufferPool(int numRequiredBuffers,
int maxUsedBuffers)
Tries to create a buffer pool, which is guaranteed to provide at least the number of required
buffers.
|
BufferPool |
createBufferPool(int numRequiredBuffers,
int maxUsedBuffers,
int numSubpartitions,
int maxBuffersPerChannel)
Tries to create a buffer pool with an owner, which is guaranteed to provide at least the
number of required buffers.
|
void |
destroy() |
void |
destroyAllBufferPools()
Destroys all buffer pools that allocate their buffers from this buffer pool (created via
createBufferPool(int, int) ). |
void |
destroyBufferPool(BufferPool bufferPool)
Destroy callback for updating factory book keeping.
|
CompletableFuture<?> |
getAvailableFuture()
Returns a future that is completed when there are free segments in this pool.
|
long |
getAvailableMemory() |
int |
getNumberOfAvailableMemorySegments() |
int |
getNumberOfRegisteredBufferPools() |
int |
getNumberOfUsedMemorySegments() |
long |
getTotalMemory() |
int |
getTotalNumberOfMemorySegments() |
long |
getUsedMemory() |
boolean |
isDestroyed() |
void |
recycle(MemorySegment segment) |
void |
recycleMemorySegments(Collection<MemorySegment> segments) |
MemorySegment |
requestMemorySegment() |
List<MemorySegment> |
requestMemorySegments(int numberOfSegmentsToRequest) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
and, isApproximatelyAvailable, isAvailable, or
@VisibleForTesting public NetworkBufferPool(int numberOfSegmentsToAllocate, int segmentSize)
public NetworkBufferPool(int numberOfSegmentsToAllocate, int segmentSize, java.time.Duration requestSegmentsTimeout)
MemorySegment
instances managed by this pool.@Nullable public MemorySegment requestMemorySegment()
public void recycle(MemorySegment segment)
public List<MemorySegment> requestMemorySegments(int numberOfSegmentsToRequest) throws IOException
requestMemorySegments
in interface MemorySegmentProvider
IOException
public void recycleMemorySegments(Collection<MemorySegment> segments)
recycleMemorySegments
in interface MemorySegmentProvider
public void destroy()
public boolean isDestroyed()
public int getTotalNumberOfMemorySegments()
public long getTotalMemory()
public int getNumberOfAvailableMemorySegments()
public long getAvailableMemory()
public int getNumberOfUsedMemorySegments()
public long getUsedMemory()
public int getNumberOfRegisteredBufferPools()
public int countBuffers()
public CompletableFuture<?> getAvailableFuture()
getAvailableFuture
in interface AvailabilityProvider
public BufferPool createBufferPool(int numRequiredBuffers, int maxUsedBuffers) throws IOException
BufferPoolFactory
The buffer pool is of dynamic size with at least numRequiredBuffers buffers.
createBufferPool
in interface BufferPoolFactory
numRequiredBuffers
- minimum number of network buffers in this poolmaxUsedBuffers
- maximum number of network buffers this pool offersIOException
public BufferPool createBufferPool(int numRequiredBuffers, int maxUsedBuffers, int numSubpartitions, int maxBuffersPerChannel) throws IOException
BufferPoolFactory
The buffer pool is of dynamic size with at least numRequiredBuffers buffers.
createBufferPool
in interface BufferPoolFactory
numRequiredBuffers
- minimum number of network buffers in this poolmaxUsedBuffers
- maximum number of network buffers this pool offersnumSubpartitions
- number of subpartitions in this poolmaxBuffersPerChannel
- maximum number of buffers to use for each channelIOException
public void destroyBufferPool(BufferPool bufferPool)
BufferPoolFactory
destroyBufferPool
in interface BufferPoolFactory
public void destroyAllBufferPools()
createBufferPool(int, int)
).Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.