public class NetworkBufferPool extends Object implements BufferPoolFactory, org.apache.flink.core.memory.MemorySegmentProvider, AvailabilityProvider
MemorySegment instances for the network
stack.
The NetworkBufferPool creates LocalBufferPools 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| Modifier and Type | Field and Description |
|---|---|
static int |
UNBOUNDED_POOL_SIZE |
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() |
long |
getNumberOfRequestedMemorySegments() |
int |
getNumberOfUsedMemorySegments() |
long |
getRequestedMemory() |
int |
getRequestedSegmentsUsage() |
long |
getTotalMemory() |
int |
getTotalNumberOfMemorySegments() |
long |
getUsedMemory() |
boolean |
isDestroyed() |
void |
maybeLogUsageWarning() |
void |
recyclePooledMemorySegment(org.apache.flink.core.memory.MemorySegment segment)
Corresponding to
requestPooledMemorySegmentsBlocking(int) and requestPooledMemorySegment(), this method is for pooled memory segments recycling. |
void |
recycleUnpooledMemorySegments(Collection<org.apache.flink.core.memory.MemorySegment> segments)
Corresponding to
requestUnpooledMemorySegments(int), this method is for unpooled memory
segments recycling. |
org.apache.flink.core.memory.MemorySegment |
requestPooledMemorySegment()
Different from
requestUnpooledMemorySegments(int) for unpooled segments allocation. |
List<org.apache.flink.core.memory.MemorySegment> |
requestPooledMemorySegmentsBlocking(int numberOfSegmentsToRequest) |
List<org.apache.flink.core.memory.MemorySegment> |
requestUnpooledMemorySegments(int numberOfSegmentsToRequest)
Unpooled memory segments are requested directly from
NetworkBufferPool, as opposed to
pooled segments, that are requested through BufferPool that was created from this
NetworkBufferPool (see createBufferPool(int, int)). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitand, isApproximatelyAvailable, isAvailable, orpublic static final int UNBOUNDED_POOL_SIZE
@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 org.apache.flink.core.memory.MemorySegment requestPooledMemorySegment()
requestUnpooledMemorySegments(int) for unpooled segments allocation. This
method and the below requestPooledMemorySegmentsBlocking(int) method are designed to be
used from LocalBufferPool for pooled memory segments allocation. Note that these
methods for pooled memory segments requesting and recycling are prohibited from acquiring the
factoryLock to avoid deadlock.public List<org.apache.flink.core.memory.MemorySegment> requestPooledMemorySegmentsBlocking(int numberOfSegmentsToRequest) throws IOException
IOExceptionpublic void recyclePooledMemorySegment(org.apache.flink.core.memory.MemorySegment segment)
requestPooledMemorySegmentsBlocking(int) and requestPooledMemorySegment(), this method is for pooled memory segments recycling.public List<org.apache.flink.core.memory.MemorySegment> requestUnpooledMemorySegments(int numberOfSegmentsToRequest) throws IOException
NetworkBufferPool, as opposed to
pooled segments, that are requested through BufferPool that was created from this
NetworkBufferPool (see createBufferPool(int, int)). They are used for example for
exclusive RemoteInputChannel credits, that are permanently assigned to that channel,
and never returned to any BufferPool. As opposed to pooled segments, when requested,
unpooled segments needs to be accounted against numTotalRequiredBuffers, which might
require redistribution of the segments.requestUnpooledMemorySegments in interface org.apache.flink.core.memory.MemorySegmentProviderIOExceptionpublic void recycleUnpooledMemorySegments(Collection<org.apache.flink.core.memory.MemorySegment> segments)
requestUnpooledMemorySegments(int), this method is for unpooled memory
segments recycling.recycleUnpooledMemorySegments in interface org.apache.flink.core.memory.MemorySegmentProviderpublic 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 long getNumberOfRequestedMemorySegments()
public long getRequestedMemory()
public int getRequestedSegmentsUsage()
public void maybeLogUsageWarning()
public int countBuffers()
public CompletableFuture<?> getAvailableFuture()
getAvailableFuture in interface AvailabilityProviderpublic BufferPool createBufferPool(int numRequiredBuffers, int maxUsedBuffers) throws IOException
BufferPoolFactoryThe buffer pool is of dynamic size with at least numRequiredBuffers buffers.
createBufferPool in interface BufferPoolFactorynumRequiredBuffers - minimum number of network buffers in this poolmaxUsedBuffers - maximum number of network buffers this pool offersIOExceptionpublic BufferPool createBufferPool(int numRequiredBuffers, int maxUsedBuffers, int numSubpartitions, int maxBuffersPerChannel) throws IOException
BufferPoolFactoryThe buffer pool is of dynamic size with at least numRequiredBuffers buffers.
createBufferPool in interface BufferPoolFactorynumRequiredBuffers - 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 channelIOExceptionpublic void destroyBufferPool(BufferPool bufferPool)
BufferPoolFactorydestroyBufferPool in interface BufferPoolFactorypublic void destroyAllBufferPools()
createBufferPool(int, int)).Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.