scwhittle commented on code in PR #31784:
URL: https://github.com/apache/beam/pull/31784#discussion_r1703754946


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/work/refresh/ActiveWorkRefresher.java:
##########
@@ -103,5 +126,67 @@ private void invalidateStuckCommits() {
     }
   }
 
-  protected abstract void refreshActiveWork();
+  private void refreshActiveWork() {
+    Instant refreshDeadline = 
clock.get().minus(Duration.millis(activeWorkRefreshPeriodMillis));
+    Map<HeartbeatSender, Heartbeats> heartbeatsBySender =
+        aggregateHeartbeatsBySender(refreshDeadline);
+
+    List<CompletableFuture<Void>> fanOutRefreshActiveWork = new ArrayList<>();
+
+    // Send the first heartbeat on the calling thread, and fan out the rest 
via the
+    // fanOutActiveWorkRefreshExecutor.
+    @Nullable Map.Entry<HeartbeatSender, Heartbeats> firstHeartbeat = null;
+    for (Map.Entry<HeartbeatSender, Heartbeats> heartbeat : 
heartbeatsBySender.entrySet()) {
+      if (firstHeartbeat == null) {
+        firstHeartbeat = heartbeat;
+      } else {
+        fanOutRefreshActiveWork.add(
+            CompletableFuture.runAsync(
+                () -> sendHeartbeatSafely(heartbeat), 
fanOutActiveWorkRefreshExecutor));
+      }
+    }
+
+    sendHeartbeatSafely(firstHeartbeat);

Review Comment:
   Oops we lost the empty case in refactoring, sending PR.



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