flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From NicoK <...@git.apache.org>
Subject [GitHub] flink pull request #4485: [FLINK-7378][core]Create a fix size (non rebalanci...
Date Thu, 21 Sep 2017 09:23:46 GMT
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4485#discussion_r140189504
  
    --- Diff: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
---
    @@ -188,14 +195,14 @@ public void testRequestMemorySegmentsLessThanTotalBuffers() throws
Exception {
     
     		NetworkBufferPool globalPool = new NetworkBufferPool(numBuffers, 128, MemoryType.HEAP);
     
    -		List<MemorySegment> memorySegments = Collections.emptyList();
     		try {
    -			memorySegments = globalPool.requestMemorySegments(numBuffers / 2);
    -
    +			List<MemorySegment> memorySegments = globalPool.requestMemorySegments(numBuffers
/ 2);
     			assertEquals(memorySegments.size(), numBuffers / 2);
    -		} finally {
    +
     			globalPool.recycleMemorySegments(memorySegments);
     			assertEquals(globalPool.getNumberOfAvailableMemorySegments(), numBuffers);
    +		} finally {
    --- End diff --
    
    Actually, in case one of the assertions fails, we also need to recycle the requested memory
segments since they are not in the pool anymore. How about this?
    
    ```
    		List<MemorySegment> memorySegments = Collections.emptyList();
    		try {
    			memorySegments = globalPool.requestMemorySegments(numBuffers / 2);
    			assertEquals(memorySegments.size(), numBuffers / 2);
    
    			globalPool.recycleMemorySegments(memorySegments);
    			memorySegments.clear();
    			assertEquals(globalPool.getNumberOfAvailableMemorySegments(), numBuffers);
    		} finally {
    			globalPool.recycleMemorySegments(memorySegments); // just in case
    			globalPool.destroy();
    		}
    ```


---

Mime
View raw message