[
https://issues.apache.org/jira/browse/FLINK-7378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16146998#comment-16146998
]
ASF GitHub Bot commented on FLINK-7378:
---------------------------------------
Github user NicoK commented on a diff in the pull request:
https://github.com/apache/flink/pull/4485#discussion_r136021056
--- Diff:
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
---
@@ -168,4 +171,45 @@ public void testDestroyAll() {
fail(e.getMessage());
}
}
+
+ @Test
+ public void testRequestAndRecycleMemorySegments() throws Exception {
+ final int numBuffers = 10;
+
+ NetworkBufferPool globalPool = new
NetworkBufferPool(numBuffers, 128, MemoryType.HEAP);
+
+ List<MemorySegment> segments = null;
+ // request buffers from global pool with illegal argument
+ try {
+ segments = globalPool.requestMemorySegments(0);
+ fail("Should throw an IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertNull(segments);
+
assertEquals(globalPool.getNumberOfAvailableMemorySegments(), numBuffers);
+ }
+
+ // common case to request buffers less than the total capacity
of global pool
+ final int numRequiredBuffers = 8;
+ segments = globalPool.requestMemorySegments(numRequiredBuffers);
+
+ assertNotNull(segments);
+ assertEquals(segments.size(), numRequiredBuffers);
+
+ // recycle all the requested buffers to global pool
+ globalPool.recycleMemorySegments(segments);
+
+ assertEquals(globalPool.getNumberOfAvailableMemorySegments(),
numBuffers);
+
+ // uncommon case to request buffers exceeding the total
capacity of global pool
+ try {
+ segments = null;
+ segments = globalPool.requestMemorySegments(11);
--- End diff --
same here - can you create a separate test method for this (invalid) use
case?
> Create a fix size (non rebalancing) buffer pool type for the floating buffers
> -----------------------------------------------------------------------------
>
> Key: FLINK-7378
> URL: https://issues.apache.org/jira/browse/FLINK-7378
> Project: Flink
> Issue Type: Sub-task
> Components: Core
> Reporter: zhijiang
> Assignee: zhijiang
> Fix For: 1.4.0
>
>
> Currently the number of network buffers in {{LocalBufferPool}} for
> {{SingleInputGate}} is limited by {{a * <number of channels> + b}}, where a
> is the number of exclusive buffers for each channel and b is the number of
> floating buffers shared by all channels.
> Considering the credit-based flow control feature, we want to create a fix
> size buffer pool used to manage the floating buffers for {{SingleInputGate}}.
> And the exclusive buffers are assigned to {{InputChannel}}s directly.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)