Github user NicoK commented on a diff in the pull request:
https://github.com/apache/flink/pull/4758#discussion_r148401163
--- Diff:
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/BufferPoolFactoryTest.java
---
@@ -53,9 +64,89 @@ public void verifyAllBuffersReturned() {
networkBufferPool.destroy();
}
- @Test(expected = IOException.class)
- public void testRequireMoreThanPossible() throws IOException {
-
networkBufferPool.createBufferPool(networkBufferPool.getTotalNumberOfMemorySegments()
* 2, Integer.MAX_VALUE);
+ /**
+ * Tests creating one buffer pool which requires more buffers than
available.
+ */
+ @Test
+ public void testRequireMoreThanPossible1() throws IOException {
+ expectedException.expect(IOException.class);
+ expectedException.expectMessage("Insufficient number of network
buffers");
+
+
networkBufferPool.createBufferPool(networkBufferPool.getTotalNumberOfMemorySegments()
+ 1,
+ Integer.MAX_VALUE);
+ }
+
+ /**
+ * Tests creating two buffer pools which together require more buffers
than available.
+ */
+ @Test
+ public void testRequireMoreThanPossible2() throws IOException {
+ expectedException.expect(IOException.class);
+ expectedException.expectMessage("Insufficient number of network
buffers");
+
+ networkBufferPool.createBufferPool(numBuffers / 2 + 1,
numBuffers);
+ networkBufferPool.createBufferPool(numBuffers / 2 + 1,
numBuffers);
+ }
+
+ /**
+ * Tests creating two buffer pools which together require as many
buffers as available but where
+ * there are less buffers available to the {@link NetworkBufferPool} at
the time of the second
+ * {@link LocalBufferPool} creation.
+ */
+ @Test
+ public void testOverprovisioned() throws IOException {
+ int buffersToTakeFromPool1 = numBuffers / 2 + 1;
+ int buffersToTakeFromPool2 = numBuffers -
buffersToTakeFromPool1;
+
+ List<Buffer> buffers = new ArrayList<>(numBuffers);
+ BufferPool lbp1 = null, lbp2 = null;
+ try {
+ lbp1 =
networkBufferPool.createBufferPool(buffersToTakeFromPool2, numBuffers);
--- End diff --
that's correct - although I also had to think about this one more time,
last time I looked at this commit: `buffersToTakeFromPool2` is the minimum
number of buffers reserved for this pool while `buffersToTakeFromPool1` is the
actual number of buffers we request from the pool - I could add a comment
regarding this to the variable declaration
---