Skip to content

Commit

Permalink
[INLONG-10434][Manager] Allow creating cluster nodes without setting …
Browse files Browse the repository at this point in the history
…port (apache#10435)
  • Loading branch information
fuweng11 authored Jun 26, 2024
1 parent db8944c commit 147c49a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public class ClusterNodeRequest {
private String ip;

@ApiModelProperty(value = "Cluster port")
@NotNull(message = "port cannot be null")
private Integer port;

@ApiModelProperty(value = "Username")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,20 @@ private void evictClusterNode(HeartbeatMsg heartbeat) {
}

// protocolType may be null, and the protocolTypes' length may be less than ports' length
String[] ports = heartbeat.getPort().split(InlongConstants.COMMA);
String[] ips = heartbeat.getIp().split(InlongConstants.COMMA);
String port = heartbeat.getPort();
String[] ports = null;
if (StringUtils.isNotBlank(port)) {
ports = port.split(InlongConstants.COMMA);
if (ports.length < ips.length) {
ports = null;
}
}
String protocolType = heartbeat.getProtocolType();
String[] protocolTypes = null;
if (StringUtils.isNotBlank(protocolType) && ports.length > 1) {
if (StringUtils.isNotBlank(protocolType) && ips.length > 1) {
protocolTypes = protocolType.split(InlongConstants.COMMA);
if (protocolTypes.length < ports.length) {
if (protocolTypes.length < ips.length) {
protocolTypes = null;
}
}
Expand All @@ -274,11 +281,13 @@ private void evictClusterNode(HeartbeatMsg heartbeat) {
return;
}

for (int i = 0; i < ports.length; i++) {
for (int i = 0; i < ips.length; i++) {
// deep clone the heartbeat
HeartbeatMsg heartbeatMsg = JsonUtils.parseObject(JsonUtils.toJsonByte(heartbeat), HeartbeatMsg.class);
assert heartbeatMsg != null;
heartbeatMsg.setPort(ports[i].trim());
if (StringUtils.isNotBlank(port) && ports != null) {
heartbeatMsg.setPort(ports[i].trim());
}
heartbeatMsg.setIp(ips[i].trim());
if (protocolTypes != null) {
heartbeatMsg.setProtocolType(protocolTypes[i]);
Expand Down

0 comments on commit 147c49a

Please sign in to comment.