merlimat opened a new pull request #6235: Use fully qualified hostname as 
default to advertise brokers
URL: https://github.com/apache/pulsar/pull/6235
 
 
   ### Motivation
   
   There is a difference in getting hostnames between Java 8 and Java 11. 
   
   In Java 8 `InetAddress.getLocalHost().getHostName()` was returning the fully 
qualified hostname while in 11 is returning the simple hostname. We should 
rather use the `getCanonicalHostName()` which is return the fully qualified 
hostname. 
   This is the same method to get the advertised address for bookies as well.
   
   Example: 
   
   ```java
   import java.net.InetAddress;
   public class test{
     public static void main(String[] args) throws Exception {
       System.out.println("Hostname: " + 
InetAddress.getLocalHost().getHostName());
       System.out.println("Canonical Hostname: " + 
InetAddress.getLocalHost().getCanonicalHostName());
     }
   }
   ```
   
   ```shell
   # Java 8
   $ java test
   Hostname: broker-0.broker.pulsar.svc.cluster.local
   Canonical Hostname: broker-0.broker.pulsar.svc.cluster.local
   ```
   
   ```shell
   # Java 11
   $ java test
   Hostname: broker-0
   Canonical Hostname: broker-0.broker.pulsar.svc.cluster.local
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to