pnowojski commented on a change in pull request #15885:
URL: https://github.com/apache/flink/pull/15885#discussion_r644050591



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateSerializer.java
##########
@@ -61,7 +61,7 @@
 

Review comment:
       nit `implements AutoCloseable`?

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/RecoveredChannelStateHandler.java
##########
@@ -83,8 +91,12 @@
     }
 
     @Override
-    public void recover(InputChannelInfo channelInfo, int oldSubtaskIndex, 
Buffer buffer)
+    public void recover(

Review comment:
       nit: As I mentioned sometime ago, can we add a javadoc documenting the 
contract, that
   > this method is taking over the ownership of the `bufferWithContext` and is 
   > fully responsible for cleaning it up both on the happy path and in case of 
an error
   
   ? And maybe add the same comment in `RemoteInputChannel#onBuffer`?
   
   (can be done as a hotfix commit at the end)

##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/RecoveredChannelStateHandlerTest.java
##########
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.checkpoint.channel;
+
+import org.apache.flink.runtime.checkpoint.InflightDataRescalingDescriptor;
+import 
org.apache.flink.runtime.checkpoint.InflightDataRescalingDescriptor.InflightDataGateOrPartitionRescalingDescriptor;
+import 
org.apache.flink.runtime.checkpoint.InflightDataRescalingDescriptor.InflightDataGateOrPartitionRescalingDescriptor.MappingType;
+import org.apache.flink.runtime.checkpoint.RescaleMappings;
+import org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter;
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferBuilder;
+import org.apache.flink.runtime.io.network.buffer.NetworkBufferPool;
+import org.apache.flink.runtime.io.network.partition.ResultPartition;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionBuilder;
+import 
org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder;
+import org.apache.flink.runtime.io.network.partition.consumer.InputGate;
+import org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate;
+import 
org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+
+import static org.junit.Assert.assertEquals;
+
+/** Test of different implementation of {@link 
InputChannelRecoveredStateHandler}. */
+public class RecoveredChannelStateHandlerTest<Info, Context> {
+
+    @Test
+    public void testRecycleBufferForInputChannelBeforeRecoverWasCalled() 
throws Exception {

Review comment:
       optional comment:
   
   If you want to avoid some of the code duplication, maybe we can split this 
test into two test classes. `RecoveredChannelStateHandlerTest` -> 
`InputRecoveredChannelStateHandlerTest` and 
`OutputRecoveredChannelStateHandlerTest`. 
   
   Both input and output variants could do initialisation in the `@Before` 
methods for example:
   ```
   private NetworkBufferPool networkBufferPool;
   private SingleInputGate inputGate;
   private InputChannelRecoveredStateHandler icsHander;
   
   @Before
   public void setUp() {
           networkBufferPool = new NetworkBufferPool(preAllocatedSegments, 
1024);
   
           // and: Configured input gate with recovered channel.
           inputGate =
                   new SingleInputGateBuilder()
                           
.setChannelFactory(InputChannelBuilder::buildLocalRecoveredChannel)
                           .setSegmentProvider(networkBufferPool)
                           .build();
   
           icsHander = buildInputChannelStateHandler(inputGate);  
   }
   
   @Test
   public void testRecycleBufferForInputChannelBeforeRecoverWasCalled() { ...}
   
   
   @Test
   public void testRecycleBufferForInputChannelAfterRecoverWasCalled() {...}
   
   
   ```
   ?




-- 
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]


Reply via email to