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

[ISSUE 2784] get local host from config file #2785

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class RackawareEnsemblePlacementPolicyImpl extends TopologyAwareEnsembleP
protected boolean enforceMinNumRacksPerWriteQuorum;
protected boolean ignoreLocalNodeInPlacementPolicy;

public static final String ADVERTISED_ADDRESS = "advertisedAddress";
public static final String REPP_DNS_RESOLVER_CLASS = "reppDnsResolverClass";
public static final String REPP_RANDOM_READ_REORDERING = "ensembleRandomReadReordering";

Expand Down Expand Up @@ -135,6 +136,9 @@ public class RackawareEnsemblePlacementPolicyImpl extends TopologyAwareEnsembleP

private String defaultRack = NetworkTopology.DEFAULT_RACK;

// local host/ip
private String advertisedAddress;

RackawareEnsemblePlacementPolicyImpl() {
this(false);
}
Expand Down Expand Up @@ -206,7 +210,9 @@ public Integer getSample() {
BookieNode bn = null;
if (!ignoreLocalNodeInPlacementPolicy) {
try {
bn = createDummyLocalBookieNode(InetAddress.getLocalHost().getHostAddress());
InetAddress address = this.advertisedAddress == null ? InetAddress.getLocalHost() :
InetAddress.getByName(this.advertisedAddress);
bn = createDummyLocalBookieNode(address.getHostAddress());
} catch (IOException e) {
LOG.error("Failed to get local host address : ", e);
}
Expand Down Expand Up @@ -253,6 +259,7 @@ public RackawareEnsemblePlacementPolicyImpl initialize(ClientConfiguration conf,
StatsLogger statsLogger,
BookieAddressResolver bookieAddressResolver) {
this.bookieAddressResolver = bookieAddressResolver;
this.advertisedAddress = conf.getString(ADVERTISED_ADDRESS, null);
DNSToSwitchMapping dnsResolver;
if (optionalDnsResolver.isPresent()) {
dnsResolver = optionalDnsResolver.get();
Expand Down