[ https://issues.apache.org/jira/browse/FLINK-7394?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16179305#comment-16179305 ]
ASF GitHub Bot commented on FLINK-7394: --------------------------------------- Github user NicoK commented on a diff in the pull request: https://github.com/apache/flink/pull/4499#discussion_r140833417 --- Diff: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/RemoteInputChannelTest.java --- @@ -281,6 +286,73 @@ public void testProducerFailedException() throws Exception { ch.getNextBuffer(); } + /** + * Tests {@link RemoteInputChannel#recycle(MemorySegment)}, verifying the exclusive segment is + * recycled to available buffers directly and it triggers notify of announced credit. + */ + @Test + public void testRecycleExclusiveBufferBeforeReleased() throws Exception { + final SingleInputGate inputGate = mock(SingleInputGate.class); + final RemoteInputChannel inputChannel = spy(createRemoteInputChannel(inputGate)); + + // Recycle exclusive segment + inputChannel.recycle(MemorySegmentFactory.getFactory().allocateUnpooledSegment(1024, inputChannel)); + + assertEquals("There should have one available buffer after recycle.", + 1, inputChannel.getNumberOfAvailableBuffers()); + verify(inputChannel, times(1)).notifyCreditAvailable(); --- End diff -- can you add one more `inputChannel.recycle(MemorySegmentFactory.getFactory().allocateUnpooledSegment(1024, inputChannel))` call and verify `inputChannel.getNumberOfAvailableBuffers()` and that `notifyCreditAvailable()` is not called again? > Manage exclusive buffers in RemoteInputChannel > ---------------------------------------------- > > Key: FLINK-7394 > URL: https://issues.apache.org/jira/browse/FLINK-7394 > Project: Flink > Issue Type: Sub-task > Components: Core > Reporter: zhijiang > Assignee: zhijiang > Fix For: 1.4.0 > > > This is a part of work for credit-based network flow control. > The basic works are: > * Exclusive buffers are assigned to {{RemoteInputChannel}} after created by > {{SingleInputGate}}. > * {{RemoteInputChannel}} implements {{BufferRecycler}} interface to manage > the exclusive buffers itself. -- This message was sent by Atlassian JIRA (v6.4.14#64029)