leosanqing commented on code in PR #5332:
URL: https://github.com/apache/inlong/pull/5332#discussion_r936777405
##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/HeartbeatManager.java:
##########
@@ -106,6 +176,50 @@ private TaskSnapshotRequest getHeartBeat() {
return taskSnapshotRequest;
}
+ /**
+ * build heartbeat message of agent
+ */
+ private HeartbeatMsg buildHeartbeatMsg() {
+ HeartbeatMsg heartbeatMsg = new HeartbeatMsg();
+ final String agentIp = AgentUtils.fetchLocalIp();
+ final int agentPort = conf.getInt(AGENT_HTTP_PORT,
DEFAULT_AGENT_HTTP_PORT);
+ final String clusterName = conf.get(AGENT_CLUSTER_NAME);
+ final String clusterTag = conf.get(AGENT_CLUSTER_TAG);
+ heartbeatMsg.setIp(agentIp);
+ heartbeatMsg.setPort(agentPort);
+ heartbeatMsg.setComponentType(ComponentTypeEnum.Agent.getName());
+ heartbeatMsg.setReportTime(System.currentTimeMillis());
+ if (StringUtils.isNotBlank(clusterName)) {
Review Comment:
Personally I think it would be better. The above is the logic of getting
attributes, and the following is the logic of constructing the heartbeatMsg
object
```
final String agentIp = AgentUtils.fetchLocalIp();
final int agentPort = conf.getInt(AGENT_HTTP_PORT,
DEFAULT_AGENT_HTTP_PORT);
final String clusterName = conf.get(AGENT_CLUSTER_NAME);
final String clusterTag = conf.get(AGENT_CLUSTER_TAG);
HeartbeatMsg heartbeatMsg = new HeartbeatMsg();
heartbeatMsg.setIp(agentIp);
heartbeatMsg.setPort(agentPort);
heartbeatMsg.setComponentType(ComponentTypeEnum.Agent.getName());
heartbeatMsg.setReportTime(System.currentTimeMillis());
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]