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

[GitHub] [inlong] fuweng11 opened a new pull request, #8028: [INLONG-8021][Manager] Periodically delete sources with inconsistent states

fuweng11 opened a new pull request, #8028:
URL: https://github.com/apache/inlong/pull/8028

   
   ### Prepare a Pull Request
   
   - Fixes #8021 
   
   ### Motivation
   
   Periodically delete sources with inconsistent states.
   
   ### Modifications
   
   Periodically delete sources with inconsistent states.


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


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

Posted by "healchow (via GitHub)" <gi...@apache.org>.
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-unsubscribe@inlong.apache.org

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


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

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #8028:
URL: https://github.com/apache/inlong/pull/8028#discussion_r1194512285


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -663,4 +670,22 @@ public void run() {
         }
     }
 
+    /**
+     * update task which in an incorrect state
+     */
+    private class TaskCleanRunnable implements Runnable {
+
+        @Override
+        public void run() {
+            while (true) {
+                try {
+                    sourceMapper.updateStatusByDeleted();
+                    Thread.sleep(60 * 10000);

Review Comment:
   Fixed



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -138,11 +140,16 @@ public class AgentServiceImpl implements AgentService {
      */
     @PostConstruct
     private void startHeartbeatTask() {
-        if (enabled) {
+        if (updateTaskTimeoutEnabled) {
             UpdateTaskRunnable taskRunnable = new UpdateTaskRunnable();
             this.executorService.execute(taskRunnable);
             LOGGER.info("update task status started successfully");
         }
+        if (sourceCleanEnabled) {
+            TaskCleanRunnable taskCleanRunnable = new TaskCleanRunnable();
+            this.executorService.execute(taskCleanRunnable);

Review Comment:
   done



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


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

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #8028:
URL: https://github.com/apache/inlong/pull/8028#discussion_r1194552719


##########
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:
   done



##########
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);
             LOGGER.info("update task status started successfully");
         }
+        if (sourceCleanEnabled) {
+            ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();

Review Comment:
   done



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


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

Posted by "healchow (via GitHub)" <gi...@apache.org>.
healchow commented on code in PR #8028:
URL: https://github.com/apache/inlong/pull/8028#discussion_r1194533835


##########
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);
             LOGGER.info("update task status started successfully");
         }
+        if (sourceCleanEnabled) {
+            ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();

Review Comment:
   Name to "scheduled-source-deleted-%d".



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


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

Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #8028:
URL: https://github.com/apache/inlong/pull/8028#discussion_r1194009350


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -663,4 +670,22 @@ public void run() {
         }
     }
 
+    /**
+     * update task which in an incorrect state
+     */
+    private class TaskCleanRunnable implements Runnable {
+
+        @Override
+        public void run() {
+            while (true) {
+                try {
+                    sourceMapper.updateStatusByDeleted();
+                    Thread.sleep(60 * 10000);

Review Comment:
   Magic number



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -138,11 +140,16 @@ public class AgentServiceImpl implements AgentService {
      */
     @PostConstruct
     private void startHeartbeatTask() {
-        if (enabled) {
+        if (updateTaskTimeoutEnabled) {
             UpdateTaskRunnable taskRunnable = new UpdateTaskRunnable();
             this.executorService.execute(taskRunnable);
             LOGGER.info("update task status started successfully");
         }
+        if (sourceCleanEnabled) {
+            TaskCleanRunnable taskCleanRunnable = new TaskCleanRunnable();
+            this.executorService.execute(taskCleanRunnable);

Review Comment:
   Please use **_ScheduledExcutor_** to schedule the update and clean task.
   There is no need to make a thread pool since you construct a **Runable** but never exits with condition, which will occupy one thread directly and nerver return it back to the pool



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


[GitHub] [inlong] dockerzhang merged pull request #8028: [INLONG-8021][Manager] Periodically delete sources with inconsistent states

Posted by "dockerzhang (via GitHub)" <gi...@apache.org>.
dockerzhang merged PR #8028:
URL: https://github.com/apache/inlong/pull/8028


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


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

Posted by "healchow (via GitHub)" <gi...@apache.org>.
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