healchow commented on code in PR #8028:
URL: https://github.com/apache/inlong/pull/8028#discussion_r1194532005


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -138,11 +144,30 @@ public class AgentServiceImpl implements AgentService {
      */
     @PostConstruct
     private void startHeartbeatTask() {
-        if (enabled) {
-            UpdateTaskRunnable taskRunnable = new UpdateTaskRunnable();
-            this.executorService.execute(taskRunnable);
+        if (updateTaskTimeoutEnabled) {
+            ScheduledExecutorService executor = 
Executors.newSingleThreadScheduledExecutor();
+            executor.scheduleWithFixedDelay(() -> {
+                try {
+                    sourceMapper.updateStatusToTimeout(beforeSeconds);
+                    LOGGER.info("update task status successfully");
+                } catch (Throwable t) {
+                    LOGGER.error("update task status error", t);
+                }
+            }, 0, beforeSeconds, TimeUnit.SECONDS);

Review Comment:
   1. Suggest add a new interval params, not reuse the `beforeSeconds`, at the 
same time, the interval should longer, such as 300 seconds or bigger.
   
   2. Please add a name for the thread pool, such as: 
       ```java
       ThreadFactory factory = new ThreadFactoryBuilder()
               .setNameFormat("scheduled-source-timeout-%d")
               .setDaemon(true)
               .build();
       ScheduledExecutorService executor  = 
Executors.newSingleThreadScheduledExecutor(factory);
       ```



-- 
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: commits-unsubscr...@inlong.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to