lindong28 commented on code in PR #144:
URL: https://github.com/apache/flink-ml/pull/144#discussion_r949974282


##########
flink-ml-iteration/src/main/java/org/apache/flink/iteration/operator/HeadOperator.java:
##########
@@ -376,29 +379,37 @@ public void endInput() throws Exception {
         InputChannel inputChannel =
                 
getContainingTask().getEnvironment().getAllInputGates()[0].getChannel(0);
 
-        boolean endOfPartitionReceived = false;
-        long lastTriggerCheckpointId = 0;
-        while (!endOfPartitionReceived && status != 
HeadOperatorStatus.TERMINATED) {
-            mailboxExecutor.tryYield();
-            Thread.sleep(200);
-
-            List<AbstractEvent> events = parseInputChannelEvents(inputChannel);
-
-            for (AbstractEvent event : events) {
-                if (event instanceof CheckpointBarrier) {
-                    CheckpointBarrier barrier = (CheckpointBarrier) event;
-                    if (barrier.getId() > lastTriggerCheckpointId) {
-                        getContainingTask()
-                                .triggerCheckpointAsync(
-                                        new CheckpointMetaData(
-                                                barrier.getId(), 
barrier.getTimestamp()),
-                                        barrier.getCheckpointOptions());
-                        lastTriggerCheckpointId = barrier.getId();
-                    }
-
-                } else if (event instanceof EndOfPartitionEvent) {
-                    endOfPartitionReceived = true;
-                }
+        AtomicBoolean endOfPartitionReceived = new AtomicBoolean(false);
+        AtomicLong lastTriggerCheckpointId = new AtomicLong(0);
+
+        while (!endOfPartitionReceived.get() && status != 
HeadOperatorStatus.TERMINATED) {
+            Future<Void> future =
+                    mailboxExecutor.submit(

Review Comment:
   It introduces a spin loop. We typically should avoid spin loop due to its 
waste of CPU cycles.



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