Skip to content

Commit

Permalink
[INLONG-10611][Agent] Update configuration only when the version numb…
Browse files Browse the repository at this point in the history
…er is increased
  • Loading branch information
justinwwhuang committed Jul 11, 2024
1 parent e4d5007 commit 72fc68c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -194,19 +196,23 @@ private Runnable configFetchThread() {
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);
taskProfiles.add(profile);
});
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);
Expand Down

0 comments on commit 72fc68c

Please sign in to comment.