vergilchiu commented on issue #6376:
URL:
https://github.com/apache/incubator-doris/issues/6376#issuecomment-892472378
I read the addBackend code .
When adding backend , doris will validate host and port , and replace
hostname with ip.
I wonder that why replacing hostname with ip ? If so , fe will not save ip
instead of hostname .
Because in some deploy scenarios , it is necessary to use hostname instead
of ip.
class : org.apache.doris.system. SystemInfoService
```java
public static Pair<String, Integer> validateHostAndPort(String hostPort)
throws AnalysisException {
hostPort = hostPort.replaceAll("\\s+", "");
if (hostPort.isEmpty()) {
throw new AnalysisException("Invalid host port: " + hostPort);
}
String[] pair = hostPort.split(":");
if (pair.length != 2) {
throw new AnalysisException("Invalid host port: " + hostPort);
}
String host = pair[0];
if (Strings.isNullOrEmpty(host)) {
throw new AnalysisException("Host is null");
}
int heartbeatPort = -1;
try {
// validate host
if (!InetAddressValidator.getInstance().isValid(host)) {
// maybe this is a hostname
// if no IP address for the host could be found, 'getByName'
// will throw
// UnknownHostException
InetAddress inetAddress = InetAddress.getByName(host);
//**************************
//here, replace hostname with ip
host = inetAddress.getHostAddress();
}
// validate port
heartbeatPort = Integer.parseInt(pair[1]);
if (heartbeatPort <= 0 || heartbeatPort >= 65536) {
throw new AnalysisException("Port is out of range: " +
heartbeatPort);
}
return new Pair<String, Integer>(host, heartbeatPort);
} catch (UnknownHostException e) {
throw new AnalysisException("Unknown host: " + e.getMessage());
} catch (Exception e) {
throw new AnalysisException("Encounter unknown exception: " +
e.getMessage());
}
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]