This is an automated email from the ASF dual-hosted git repository.

ayegorov pushed a commit to branch branch-4.11
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/branch-4.11 by this push:
     new 8d71535  Stream storage endpoint from hostname to return 
fully-qualified name in Java 11+
8d71535 is described below

commit 8d71535b2b568390a601a2d7795a59c6b93c6004
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 fe520e6..c83a0e7 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
@@ -111,7 +111,7 @@ public class StorageServer {
     public static Endpoint createLocalEndpoint(int port, boolean useHostname) 
throws UnknownHostException {
         String hostname;
         if (useHostname) {
-            hostname = InetAddress.getLocalHost().getHostName();
+            hostname = InetAddress.getLocalHost().getCanonicalHostName();
         } else {
             hostname = InetAddress.getLocalHost().getHostAddress();
         }

Reply via email to