zhijiangW commented on a change in pull request #9993:
[FLINK-14498][runtime]Introduce NetworkBufferPool#isAvailable() for interacting
with LocalBufferPool.
URL: https://github.com/apache/flink/pull/9993#discussion_r340474221
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPoolTest.java
##########
@@ -403,6 +405,32 @@ public void testBoundedBuffer() throws Exception {
assertEquals(1,
localBufferPool.getNumberOfAvailableMemorySegments());
}
+ @Test
+ public void testIsAvailable() throws Exception {
+
+ // the local buffer pool should be in available state initially
+ assertTrue(localBufferPool.isAvailable().isDone());
+
+ // request one buffer
+ final Buffer buffer =
checkNotNull(localBufferPool.requestBuffer());
+ assertFalse(localBufferPool.isAvailable().isDone());
+
+ // set the pool size
+ localBufferPool.setNumBuffers(2);
+ assertTrue(localBufferPool.isAvailable().isDone());
+
+ // reset the pool size
+ localBufferPool.setNumBuffers(1);
+ assertFalse(localBufferPool.isAvailable().isDone());
+
+ final CompletableFuture<?> availableFuture =
localBufferPool.isAvailable();
Review comment:
nit: it is better to put it together either with above or below for
readable. E.g.
```
// reset the pool size
localBufferPool.setNumBuffers(1);
final CompletableFuture<?> availableFuture = localBufferPool.isAvailable();
assertFalse(availableFuture.isDone());
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services