This is an automated email from the ASF dual-hosted git repository.
ayegorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new cb28499 Stream storage endpoint from hostname to return
fully-qualified name in Java 11+
cb28499 is described below
commit cb284995fbfc23441be10b4465ed2985b64d5ae4
Author: Chris Bartholomew <[email protected]>
AuthorDate: Mon Feb 1 20:57:15 2021 -0500
Stream storage endpoint from hostname to return fully-qualified name in
Java 11+
Descriptions of the changes in this PR:
Update how hostname is retrieved when using hostname as identifier for
stream storage to work consistenly between Java 8 and Java 11.
### Motivation
Between Java 8 and Java 11, the value returned by
`InetAddress.getLocalHost().getHostName()` changed from being the fully
qualified name to just the short hostname. When running in a Kubernetes
environment, it is necessary for the endpoint to be identied by its fully
qualified name so that clients can connect.
This same change was made in Pulsar in
https://github.com/apache/pulsar/pull/6235.
I have tested this change in Kubernetes environment using Java 11.
### Changes
This is a simple change from `getHostName` to `getCanonicalHostName()`.
Master Issue: #2559
Reviewers: Andrey Yegorov <None>, Enrico Olivelli <[email protected]>
This closes #2571 from cdbartholomew/stream-storage-endpoint-java11
---
.../main/java/org/apache/bookkeeper/stream/server/StorageServer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java
b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java
index d5b1e50..10f29fa 100644
---
a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java
+++
b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java
@@ -117,7 +117,7 @@ public class StorageServer {
String hostname;
log.warn("Determining hostname for stream storage");
if (useHostname) {
- hostname = InetAddress.getLocalHost().getHostName();
+ hostname = InetAddress.getLocalHost().getCanonicalHostName();
} else {
hostname = InetAddress.getLocalHost().getHostAddress();
}