-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Removes bindOnLocalhost=boolean. Adds bindAddress and advertisedAddress. #26
Changes from all commits
c7e3a7a
cc08ed3
6fa126f
3745033
393e10e
3ed746e
1bec010
bf27260
368bb8d
10ccdb6
2a0920a
98f01cd
94dde8e
2b9c25c
18d3c91
2683759
1db4d34
e51b961
1ac44bf
d4c76f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,8 +37,11 @@ webServicePortTls=8443 | |
# Enable the WebSocket API service in broker | ||
webSocketServiceEnabled=false | ||
|
||
# Control whether to bind directly on localhost rather than on normal hostname | ||
bindOnLocalhost=false | ||
# Hostname or IP address the service binds on, default is 0.0.0.0. | ||
bindAddress=0.0.0.0 | ||
|
||
# Hostname or IP address the service advertises to the outside world. If not set, the value of InetAddress.getLocalHost().getHostName() is used. | ||
advertisedAddress= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving empty for clarity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the bind address was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 3745033 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the comment with "default to hostname" |
||
|
||
# Name of the cluster to which this broker belongs to | ||
clusterName= | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,12 @@ public class ServiceConfiguration { | |
private int webServicePort = 8080; | ||
// Port to use to server HTTPS request | ||
private int webServicePortTls = 8443; | ||
// Control whether to bind directly on localhost rather than on normal | ||
// hostname | ||
private boolean bindOnLocalhost = false; | ||
|
||
// Hostname or IP address the service binds on. | ||
private String bindAddress = "0.0.0.0"; | ||
|
||
// Controls which hostname is advertised to the discovery service via ZooKeeper. | ||
private String advertisedAddress; | ||
|
||
// Enable the WebSocket API service | ||
private boolean webSocketServiceEnabled = false; | ||
|
@@ -290,12 +293,20 @@ public void setWebServicePortTls(int webServicePortTls) { | |
this.webServicePortTls = webServicePortTls; | ||
} | ||
|
||
public boolean isBindOnLocalhost() { | ||
return bindOnLocalhost; | ||
public String getBindAddress() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preferably, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to avoid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, scratch that, that's a silly idea. I'll just re-throw the exception and handle where used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 3745033 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @merlimat Why would multiple threads try to initialize a single instance of |
||
return this.bindAddress; | ||
} | ||
|
||
public void setBindAddress(String bindAddress) { | ||
this.bindAddress = bindAddress; | ||
} | ||
|
||
public String getAdvertisedAddress() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, we should just return what was configured, and in any case, the fallback here should be on |
||
return this.advertisedAddress; | ||
} | ||
|
||
public void setBindOnLocalhost(boolean bindOnLocalhost) { | ||
this.bindOnLocalhost = bindOnLocalhost; | ||
public void setAdvertisedAddress(String advertisedAddress) { | ||
this.advertisedAddress = advertisedAddress; | ||
} | ||
|
||
public boolean isWebSocketServiceEnabled() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright 2016 Yahoo Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.yahoo.pulsar.broker; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
public class ServiceConfigurationUtils { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ServiceConfigurationUtils.class); | ||
|
||
public static String getDefaultOrConfiguredAddress(String configuredAddress) { | ||
if ( configuredAddress == null ) { | ||
return unsafeLocalhostResolve(); | ||
} | ||
return configuredAddress; | ||
} | ||
|
||
public static String unsafeLocalhostResolve() { | ||
try { | ||
return InetAddress.getLocalHost().getHostName(); | ||
} catch (UnknownHostException ex) { | ||
LOG.error(ex.getMessage(), ex); | ||
throw new IllegalStateException("Failed to resolve localhost name.", ex); | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naughty, I know, might be a good idea to go through logging.