1996fanrui commented on code in PR #20151:
URL: https://github.com/apache/flink/pull/20151#discussion_r1049851231


##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImpl.java:
##########
@@ -51,27 +66,40 @@ class ChannelStateWriteRequestExecutorImpl implements 
ChannelStateWriteRequestEx
     private final Thread thread;
     private volatile Exception thrown = null;
     private volatile boolean wasClosed = false;
-    private final String taskName;
+
+    private final Map<SubtaskID, Queue<ChannelStateWriteRequest>> 
unreadyQueues =
+            new ConcurrentHashMap<>();
+
+    private final JobID jobID;
+    private final Set<SubtaskID> subtasks;
+    private final AtomicBoolean isRegistering = new AtomicBoolean(true);
+    private final int numberOfSubtasksShareFile;

Review Comment:
   Sorry, you mentioned it before. 
   
   However, I encountered some difficulties during I refactor it:
   
   - `BlockingDeque.take()` will  wait until an element becomes available. 
`Deque` is hard to achieve. `BlockingDeque` is easy to implement the `producer 
& consumer` model.
   - The `loop` method access these fields continuously, do you have any 
suggestions to  refactor them using the lock?
   
   
   ```
   private void loop() throws Exception {
       while (!wasClosed) {
           try {
               ChannelStateWriteRequest request = deque.take();
               // The executor will end the registration, when the start 
request comes.
               // Because the checkpoint can be started after all tasks are 
initiated.
               if (request instanceof CheckpointStartRequest && 
isRegistering()) {
                   isRegistering.set(false);
               }
               dispatcher.dispatch(request);
           } catch (InterruptedException e) {
               if (!wasClosed) {
                   LOG.debug(
                           "Channel state executor is interrupted while waiting 
for a request (continue waiting)",
                           e);
               } else {
                   Thread.currentThread().interrupt();
               }
           }
       }
   }
   ```
   
   Sorry for not letting you know this before.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to