You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/19 01:37:03 UTC

[GitHub] [flink] Aitozi commented on a change in pull request #8455: [FLINK-12284, FLINK-12637][Network, Metrics]Fix the incorrect inputBufferUsage metric in credit-based network mode

Aitozi commented on a change in pull request #8455: [FLINK-12284,FLINK-12637][Network,Metrics]Fix the incorrect inputBufferUsage metric in credit-based network mode
URL: https://github.com/apache/flink/pull/8455#discussion_r295090881
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/InputBuffersMetricsTest.java
 ##########
 @@ -117,80 +118,61 @@ public void testBufferUsageMetrics() throws IOException, InterruptedException {
 			assertEquals(buffersPerChannel, exclusiveBuffersUsageGauge.calculateBufferPoolSize(inputGate2));
 			assertEquals(extraNetworkBuffersPerGate, floatingBuffersUsageGauge.calculateBufferPoolSize(inputGate2));
 
-			List<Buffer> exclusiveBuffers = new ArrayList<>();
 
 			// test for exclusive buffer used
-			exclusiveBuffers.add(remoteInputChannel1.requestBuffer());
-			assertEquals(1, exclusiveBuffersUsageGauge.calculateUsedBuffers(inputGate1));
-
-			for (int i = 0; i < buffersPerChannel; i++){
-				Buffer buffer = remoteInputChannel1.requestBuffer();
-				if (buffer != null) {
-					exclusiveBuffers.add(buffer);
-				} else {
-					break;
-				}
-			}
-			assertEquals(buffersPerChannel, exclusiveBuffers.size());
+			drainBuffer(buffersPerChannel, remoteInputChannel1);
+
 			assertEquals(buffersPerChannel, exclusiveBuffersUsageGauge.calculateUsedBuffers(inputGate1));
 			assertEquals(1 / 3.0, exclusiveBuffersUsageGauge.getValue(), 0.0001);
 			assertEquals(buffersPerChannel / (extraNetworkBuffersPerGate * 2 + buffersPerChannel * 3.0), inputBufferPoolUsageGauge.getValue(), 0.0001);
 
-			for (int i = 0; i < buffersPerChannel; i++){
-				Buffer buffer = remoteInputChannel2.requestBuffer();
-				if (buffer != null) {
-					exclusiveBuffers.add(buffer);
-				} else {
-					break;
-				}
-			}
-			assertEquals(buffersPerChannel * 2, exclusiveBuffers.size());
+			drainBuffer(buffersPerChannel, remoteInputChannel2);
+
 			assertEquals(buffersPerChannel * 2, exclusiveBuffersUsageGauge.calculateUsedBuffers(inputGate1));
 			assertEquals(2 / 3.0, exclusiveBuffersUsageGauge.getValue(), 0.0001);
 			assertEquals(buffersPerChannel * 2 / (extraNetworkBuffersPerGate * 2 + buffersPerChannel * 3.0), inputBufferPoolUsageGauge.getValue(), 0.0001);
 
 			// test for floating buffer used
-			List<Buffer> floatingBuffers = new ArrayList<>();
-
 			remoteInputChannel1.requestSubpartition(0);
 			remoteInputChannel1.onSenderBacklog(3);
 			assertEquals(buffersPerChannel + 3, remoteInputChannel1.unsynchronizedGetFloatingBuffersAvailable());
 
-			for (int i = 0; i < buffersPerChannel + 3; i++) {
-				Buffer buffer = remoteInputChannel1.requestBuffer();
-				if (buffer != null) {
-					floatingBuffers.add(buffer);
-				} else {
-					break;
-				}
-			}
+			drainBuffer(buffersPerChannel + 3, remoteInputChannel1);
+
 			assertEquals(0, remoteInputChannel1.unsynchronizedGetFloatingBuffersAvailable());
 			assertEquals(buffersPerChannel * 2, exclusiveBuffersUsageGauge.calculateUsedBuffers(inputGate1));
 			assertEquals(2 / 3.0, exclusiveBuffersUsageGauge.getValue(), 0.0001);
 			assertEquals((buffersPerChannel * 2 + buffersPerChannel + 3) / (extraNetworkBuffersPerGate * 2 + buffersPerChannel * 3.0), inputBufferPoolUsageGauge.getValue(), 0.0001);
 
 			List<MemorySegment> segments = new ArrayList<>();
-			for (Buffer buffer : exclusiveBuffers) {
-				segments.add(buffer.getMemorySegment());
-			}
+
 			network.getNetworkBufferPool().recycleMemorySegments(segments);
 		} finally {
 			inputGate1.close();
 			inputGate2.close();
-			network.shutdown();
+			closeableRegistry.close();
+			network.close();
 
 Review comment:
   I think this is not so good, because the closeableRegistry do not close respect to the register order which may lead to network closed before network buffers has all be recycled.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services