aloyszhang commented on code in PR #9892:
URL: https://github.com/apache/inlong/pull/9892#discussion_r1542985624


##########
inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ModuleManager.java:
##########
@@ -106,51 +120,110 @@ public String getCurrentMd5() {
         return currentMd5;
     }
 
+    public ModuleConfig getModule(Integer moduleId) {
+        return currentModules.get(moduleId);
+    }
+
     /**
-     * thread for core thread.
+     * Thread for core thread.
      *
      * @return runnable profile.
      */
     private Runnable coreThread() {
         return () -> {
-            Thread.currentThread().setName("task-manager-core");
+            Thread.currentThread().setName("module-manager-core");
+            restoreFromLocalFile(confPath);
             while (isRunnable()) {
                 try {
-                    AgentUtils.silenceSleepInMs(CORE_THREAD_SLEEP_TIME);
                     dealWithConfigQueue(configQueue);
                     
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_TASK_MGR_HEARTBEAT, "", "",
                             AgentUtils.getCurrentTime(), 1, 1);
+                    AgentUtils.silenceSleepInMs(CORE_THREAD_SLEEP_TIME);
                 } catch (Throwable ex) {
                     LOGGER.error("exception caught", ex);
                     ThreadUtils.threadThrowableHandler(Thread.currentThread(), 
ex);
+                    AgentUtils.silenceSleepInMs(CORE_THREAD_SLEEP_TIME);
                 }
             }
         };
     }
 
+    public void restoreFromLocalFile(String confPath) {
+        LOGGER.info("restore modules from local file");
+        Reader reader = null;
+        try {

Review Comment:
   try-with-resource is better just as the `saveToLocalFile` does



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