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

wenweihuang 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 7c4f57bb42 [INLONG-10611][Agent] Update configuration only when the 
version number is increased (#10612)
7c4f57bb42 is described below

commit 7c4f57bb4297ff0ffb3c79661101cb93b8d15556
Author: justinwwhuang <hww_jus...@163.com>
AuthorDate: Fri Jul 12 14:04:59 2024 +0800

    [INLONG-10611][Agent] Update configuration only when the version number is 
increased (#10612)
---
 .../org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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 b4e54071de..3746c36574 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
@@ -85,7 +85,9 @@ public class ManagerFetcher extends AbstractDaemon implements 
ProfileFetcher {
     private String clusterTag;
     private String clusterName;
     private String taskResultMd5;
+    private Integer taskResultVersion = -1;
     private String agentConfigMd5;
+    private Integer agentConfigVersion = -1;
 
     public ManagerFetcher(AgentManager agentManager) {
         this.agentManager = agentManager;
@@ -194,7 +196,8 @@ public class ManagerFetcher extends AbstractDaemon 
implements ProfileFetcher {
             while (isRunnable()) {
                 try {
                     TaskResult taskResult = getStaticConfig();
-                    if (taskResult != null && 
taskResult.getCode().equals(AgentResponseCode.SUCCESS)) {
+                    if (taskResult != null && 
taskResult.getCode().equals(AgentResponseCode.SUCCESS)
+                            && taskResultVersion < taskResult.getVersion()) {
                         List<TaskProfile> taskProfiles = new ArrayList<>();
                         taskResult.getDataConfigs().forEach((config) -> {
                             TaskProfile profile = 
TaskProfile.convertToTaskProfile(config);
@@ -202,11 +205,14 @@ public class ManagerFetcher extends AbstractDaemon 
implements ProfileFetcher {
                         });
                         
agentManager.getTaskManager().submitTaskProfiles(taskProfiles);
                         taskResultMd5 = taskResult.getMd5();
+                        taskResultVersion = taskResult.getVersion();
                     }
                     AgentConfigInfo config = getAgentConfigInfo();
-                    if (config != null && 
config.getCode().equals(AgentResponseCode.SUCCESS)) {
+                    if (config != null && 
config.getCode().equals(AgentResponseCode.SUCCESS)
+                            && agentConfigVersion < config.getVersion()) {
                         agentManager.subNewAgentConfigInfo(config);
                         agentConfigMd5 = config.getMd5();
+                        agentConfigVersion = config.getVersion();
                     }
                 } catch (Throwable ex) {
                     LOGGER.warn("exception caught", ex);

Reply via email to