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 3d754faca4 [INLONG-11685][Agent] Only use configuration files to 
provide IP address (#11686)
3d754faca4 is described below

commit 3d754faca47efad76397a1d812d9871f3a1a24cc
Author: justinwwhuang <hww_jus...@163.com>
AuthorDate: Mon Jan 20 11:35:32 2025 +0800

    [INLONG-11685][Agent] Only use configuration files to provide IP address 
(#11686)
---
 .../main/java/org/apache/inlong/agent/core/AgentStatusManager.java    | 3 ++-
 .../src/main/java/org/apache/inlong/agent/core/FileStaticManager.java | 3 ++-
 .../src/main/java/org/apache/inlong/agent/core/HeartbeatManager.java  | 3 ++-
 .../java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java   | 4 ++--
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java
 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java
index 7292c1a577..14395412bb 100644
--- 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java
+++ 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java
@@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_NAME;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_TAG;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_INSTALL_PLATFORM;
+import static org.apache.inlong.agent.constant.AgentConstants.AGENT_LOCAL_IP;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.AGENT_GLOBAL_READER_QUEUE_PERMIT;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.AGENT_GLOBAL_READER_SOURCE_PERMIT;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.AGENT_GLOBAL_WRITER_PERMIT;
@@ -221,7 +222,7 @@ public class AgentStatusManager {
 
     private AgentStatus getStatus() {
         AgentStatus data = new AgentStatus();
-        data.setAgentIp(AgentUtils.fetchLocalIp());
+        data.setAgentIp(conf.get(AGENT_LOCAL_IP));
         data.setTag(conf.get(AGENT_CLUSTER_TAG));
         data.setCluster(conf.get(AGENT_CLUSTER_NAME));
         
data.setAgentVersion(TaskManager.class.getPackage().getImplementationVersion());
diff --git 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/FileStaticManager.java
 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/FileStaticManager.java
index 774dee4247..388e2ef279 100644
--- 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/FileStaticManager.java
+++ 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/FileStaticManager.java
@@ -37,6 +37,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_NAME;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_TAG;
+import static org.apache.inlong.agent.constant.AgentConstants.AGENT_LOCAL_IP;
 
 /**
  * Collect various indicators of agent processes for backend problem analysis
@@ -109,7 +110,7 @@ public class FileStaticManager {
     }
 
     private void doPutStaticMsg(FileStatic data) {
-        data.setAgentIp(AgentUtils.fetchLocalIp());
+        data.setAgentIp(conf.get(AGENT_LOCAL_IP));
         data.setTag(conf.get(AGENT_CLUSTER_TAG));
         data.setCluster(conf.get(AGENT_CLUSTER_NAME));
         while (!queue.offer(data)) {
diff --git 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/HeartbeatManager.java
 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/HeartbeatManager.java
index f6c3046662..22ce0f0f3a 100644
--- 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/HeartbeatManager.java
+++ 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/HeartbeatManager.java
@@ -41,6 +41,7 @@ import java.util.concurrent.ThreadFactory;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_IN_CHARGES;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_NAME;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_TAG;
+import static org.apache.inlong.agent.constant.AgentConstants.AGENT_LOCAL_IP;
 import static org.apache.inlong.agent.constant.AgentConstants.AGENT_NODE_GROUP;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.AGENT_MANAGER_ADDR;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.AGENT_MANAGER_AUTH_SECRET_ID;
@@ -145,7 +146,7 @@ public class HeartbeatManager extends AbstractDaemon 
implements AbstractHeartbea
      * build heartbeat message of agent
      */
     private HeartbeatMsg buildHeartbeatMsg() {
-        final String agentIp = AgentUtils.fetchLocalIp();
+        final String agentIp = conf.get(AGENT_LOCAL_IP);
         final String clusterName = conf.get(AGENT_CLUSTER_NAME);
         final String clusterTag = conf.get(AGENT_CLUSTER_TAG);
         final String inCharges = conf.get(AGENT_CLUSTER_IN_CHARGES);
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 3ab63b0118..dc07605e3e 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
@@ -48,6 +48,7 @@ import java.util.List;
 
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_NAME;
 import static 
org.apache.inlong.agent.constant.AgentConstants.AGENT_CLUSTER_TAG;
+import static org.apache.inlong.agent.constant.AgentConstants.AGENT_LOCAL_IP;
 import static org.apache.inlong.agent.constant.AgentConstants.AGENT_UNIQ_ID;
 import static 
org.apache.inlong.agent.constant.AgentConstants.DEFAULT_AGENT_UNIQ_ID;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.AGENT_FETCHER_INTERVAL;
@@ -59,7 +60,6 @@ import static 
org.apache.inlong.agent.constant.FetcherConstants.DEFAULT_AGENT_FE
 import static 
org.apache.inlong.agent.constant.FetcherConstants.DEFAULT_AGENT_MANAGER_CONFIG_HTTP_PATH;
 import static 
org.apache.inlong.agent.constant.FetcherConstants.DEFAULT_AGENT_MANAGER_EXIST_TASK_HTTP_PATH;
 import static 
org.apache.inlong.agent.plugin.fetcher.ManagerResultFormatter.getResultData;
-import static org.apache.inlong.agent.utils.AgentUtils.fetchLocalIp;
 import static org.apache.inlong.agent.utils.AgentUtils.fetchLocalUuid;
 
 /**
@@ -259,7 +259,7 @@ public class ManagerFetcher extends AbstractDaemon 
implements ProfileFetcher {
     @Override
     public void start() throws Exception {
         // when agent start, check local ip and fetch manager ip list;
-        localIp = fetchLocalIp();
+        localIp = conf.get(AGENT_LOCAL_IP);
         uuid = fetchLocalUuid();
         submitWorker(configFetchThread());
     }

Reply via email to