Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fully qualified hostname as default to advertise brokers #6235

Merged
merged 1 commit into from
Feb 7, 2020

Conversation

merlimat
Copy link
Contributor

@merlimat merlimat commented Feb 6, 2020

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:

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());
  }
}
# Java 8
$ java test
Hostname: broker-0.broker.pulsar.svc.cluster.local
Canonical Hostname: broker-0.broker.pulsar.svc.cluster.local
# Java 11
$ java test
Hostname: broker-0
Canonical Hostname: broker-0.broker.pulsar.svc.cluster.local

@merlimat merlimat added type/bug The PR fixed a bug or issue reported a bug release/2.4.3 release/2.5.1 labels Feb 6, 2020
@merlimat merlimat added this to the 2.6.0 milestone Feb 6, 2020
@merlimat merlimat self-assigned this Feb 6, 2020
@massakam massakam merged commit 4018d0b into apache:master Feb 7, 2020
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Feb 23, 2020
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Mar 21, 2020
tuteng pushed a commit that referenced this pull request Apr 13, 2020
jiazhai pushed a commit to jiazhai/pulsar that referenced this pull request May 18, 2020
@merlimat merlimat deleted the fix-advertised-hostname-master branch June 25, 2020 18:04
sijie pushed a commit that referenced this pull request Jun 26, 2020
### Motivation

Similar to #6235, we need to ensure to always use the fully qualified  hostname
codelipenghui pushed a commit to streamnative/pulsar-archived that referenced this pull request Jul 14, 2020
…7360)

### Motivation

Similar to apache#6235, we need to ensure to always use the fully qualified  hostname

(cherry picked from commit bafb373)
wolfstudy pushed a commit that referenced this pull request Jul 29, 2020
### Motivation

Similar to #6235, we need to ensure to always use the fully qualified  hostname

(cherry picked from commit bafb373)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
…7360)

### Motivation

Similar to apache#6235, we need to ensure to always use the fully qualified  hostname
dlg99 pushed a commit to apache/bookkeeper that referenced this pull request Feb 2, 2021
…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 apache/pulsar#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 <eolivelli@gmail.com>

This closes #2571 from cdbartholomew/stream-storage-endpoint-java11
dlg99 pushed a commit to apache/bookkeeper that referenced this pull request Feb 2, 2021
…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 apache/pulsar#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 <eolivelli@gmail.com>

This closes #2571 from cdbartholomew/stream-storage-endpoint-java11
dlg99 pushed a commit to apache/bookkeeper that referenced this pull request Feb 2, 2021
…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 apache/pulsar#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 <eolivelli@gmail.com>

This closes #2571 from cdbartholomew/stream-storage-endpoint-java11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/2.4.3 release/2.5.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants