This is an automated email from the ASF dual-hosted git repository. aloyszhang 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 bcc1f3fd9f [INLONG-9946][Agent] Verify the return code, only proceed with the subsequent process if the return code is successful (#9947) bcc1f3fd9f is described below commit bcc1f3fd9f2ae50607dda2365bcafa41b2f58db1 Author: justinwwhuang <hww_jus...@163.com> AuthorDate: Tue Apr 9 17:31:02 2024 +0800 [INLONG-9946][Agent] Verify the return code, only proceed with the subsequent process if the return code is successful (#9947) --- .../main/java/org/apache/inlong/agent/installer/ManagerFetcher.java | 3 ++- .../java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ManagerFetcher.java b/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ManagerFetcher.java index 63fbffa76e..68189dc6d1 100644 --- a/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ManagerFetcher.java +++ b/inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ManagerFetcher.java @@ -25,6 +25,7 @@ import org.apache.inlong.agent.utils.HttpManager; import org.apache.inlong.agent.utils.ThreadUtils; import org.apache.inlong.common.pojo.agent.installer.ConfigRequest; import org.apache.inlong.common.pojo.agent.installer.ConfigResult; +import org.apache.inlong.common.pojo.agent.installer.InstallerCode; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -123,7 +124,7 @@ public class ManagerFetcher extends AbstractDaemon implements ProfileFetcher { while (isRunnable()) { try { ConfigResult config = getConfig(); - if (config != null) { + if (config != null && config.getCode().equals(InstallerCode.SUCCESS)) { manager.getModuleManager().submitConfig(config); } } catch (Throwable ex) { diff --git a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java index 632bb29021..f5fad95d23 100644 --- a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java +++ b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java @@ -44,7 +44,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.concurrent.TimeUnit; import static org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_NAME; import static org.apache.inlong.agent.constant.AgentConstants.AGENT_UNIQ_ID; @@ -177,7 +176,6 @@ public class ManagerFetcher extends AbstractDaemon implements ProfileFetcher { Thread.currentThread().setName("ManagerFetcher"); while (isRunnable()) { try { - int configSleepTime = conf.getInt(AGENT_FETCHER_INTERVAL, DEFAULT_AGENT_FETCHER_INTERVAL); TaskResult taskResult = getStaticConfig(); if (taskResult != null) { List<TaskProfile> taskProfiles = new ArrayList<>(); @@ -187,10 +185,12 @@ public class ManagerFetcher extends AbstractDaemon implements ProfileFetcher { }); agentManager.getTaskManager().submitTaskProfiles(taskProfiles); } - TimeUnit.SECONDS.sleep(AgentUtils.getRandomBySeed(configSleepTime)); } catch (Throwable ex) { LOGGER.warn("exception caught", ex); ThreadUtils.threadThrowableHandler(Thread.currentThread(), ex); + } finally { + AgentUtils.silenceSleepInSeconds(AgentUtils.getRandomBySeed( + conf.getInt(AGENT_FETCHER_INTERVAL, DEFAULT_AGENT_FETCHER_INTERVAL))); } } };