You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "healchow (via GitHub)" <gi...@apache.org> on 2023/05/16 02:27:20 UTC

[GitHub] [inlong] healchow commented on a diff in pull request #8028: [INLONG-8021][Manager] Periodically delete sources with inconsistent states

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`.
   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-unsubscribe@inlong.apache.org

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