This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new f756ccc7ba [INLONG-9910][Agent] Increase daily verification for 
process monitoring, reinstallation, or re downloading (#9912)
f756ccc7ba is described below

commit f756ccc7baa603624025a45e2d99490d452e062e
Author: justinwwhuang <hww_jus...@163.com>
AuthorDate: Mon Apr 1 23:42:56 2024 +0800

    [INLONG-9910][Agent] Increase daily verification for process monitoring, 
reinstallation, or re downloading (#9912)
---
 .../inlong/agent/installer/ModuleManager.java      | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git 
a/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ModuleManager.java
 
b/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ModuleManager.java
index 00dfc9668d..590644d6c3 100755
--- 
a/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ModuleManager.java
+++ 
b/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ModuleManager.java
@@ -143,6 +143,7 @@ public class ModuleManager extends AbstractDaemon {
             while (isRunnable()) {
                 try {
                     dealWithConfigQueue(configQueue);
+                    checkModules();
                     
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_TASK_MGR_HEARTBEAT, "", "",
                             AgentUtils.getCurrentTime(), 1, 1);
                     AgentUtils.silenceSleepInMs(CORE_THREAD_SLEEP_TIME);
@@ -213,6 +214,44 @@ public class ModuleManager extends AbstractDaemon {
         }
     }
 
+    private void checkModules() {
+        LOGGER.info("check modules start");
+        currentModules.values().forEach((module) -> {
+            LOGGER.info("check module current state {} {}", module.getName(), 
module.getState());
+            switch (module.getState()) {
+                case NEW:
+                    if (downloadModule(module)) {
+                        saveModuleState(module.getId(), 
ModuleStateEnum.DOWNLOADED);
+                    } else {
+                        LOGGER.error("download module {} failed, keep state in 
new", module.getName());
+                    }
+                    break;
+                case DOWNLOADED:
+                    if (isPackageDownloaded(module)) {
+                        installModule(module);
+                        saveModuleState(module.getId(), 
ModuleStateEnum.INSTALLED);
+                    } else {
+                        LOGGER.info("check module {} package failed, change 
stated to new, will download package again",
+                                module.getName());
+                        saveModuleState(module.getId(), ModuleStateEnum.NEW);
+                    }
+                    break;
+                case INSTALLED:
+                    if (!isProcessAllStarted(module)) {
+                        LOGGER.info("module {} process not all started try to 
start", module.getName());
+                        if (!startModule(module)) {
+                            LOGGER.info("start module {} failed, change state 
to downloaded", module.getState());
+                            saveModuleState(module.getId(), 
ModuleStateEnum.DOWNLOADED);
+                        }
+                    }
+                    break;
+                default:
+                    LOGGER.error("module {} invalid state {}", 
module.getName(), module.getState());
+            }
+        });
+        LOGGER.info("check modules end");
+    }
+
     private boolean updateModules(List<ModuleConfig> managerModuleList) {
         Map<Integer, ModuleConfig> modulesFromManager = new 
ConcurrentHashMap<>();
         managerModuleList.forEach((moduleConfig) -> {

Reply via email to