HBASE-4074 When a RS has hostname with uppercase letter, there are two
RS entries in master git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1143915 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c3169bf0c
commit
1e90b73574
|
@ -154,6 +154,8 @@ Release 0.91.0 - Unreleased
|
|||
HBASE-4061 getTableDirs is missing directories to skip
|
||||
HBASE-3867 when cluster is stopped and server which hosted meta region is
|
||||
removed from cluster, master breaks down after restarting cluster.
|
||||
HBASE-4074 When a RS has hostname with uppercase letter, there are two
|
||||
RS entries in master (Weihua via Ted Yu)
|
||||
|
||||
IMPROVEMENTS
|
||||
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)
|
||||
|
|
|
@ -72,7 +72,7 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
|
|||
* @param port Port number
|
||||
*/
|
||||
public HServerAddress(final String hostname, final int port) {
|
||||
this(new InetSocketAddress(hostname, port));
|
||||
this(getResolvedAddress(new InetSocketAddress(hostname, port)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,21 +80,33 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
|
|||
* @param other HServerAddress to copy from
|
||||
*/
|
||||
public HServerAddress(HServerAddress other) {
|
||||
this(new InetSocketAddress(other.getHostname(), other.getPort()));
|
||||
this(getResolvedAddress(new InetSocketAddress(other.getHostname(), other.getPort())));
|
||||
}
|
||||
|
||||
private static InetSocketAddress getResolvedAddress(InetSocketAddress address) {
|
||||
String bindAddress = getBindAddressInternal(address);
|
||||
int port = address.getPort();
|
||||
return new InetSocketAddress(bindAddress, port);
|
||||
}
|
||||
|
||||
/** @return Bind address -- the raw IP, the result of a call to
|
||||
* {@link InetSocketAddress#getAddress()#getHostAddress()} --
|
||||
* or null if cannot resolve */
|
||||
public String getBindAddress() {
|
||||
// This returns null if the address is not resolved.
|
||||
final InetAddress addr = this.address.getAddress();
|
||||
if (addr != null) return addr.getHostAddress();
|
||||
LogFactory.getLog(HServerAddress.class).error("Could not resolve the"
|
||||
+ " DNS name of " + this.address.toString());
|
||||
return null;
|
||||
return getBindAddressInternal(address);
|
||||
}
|
||||
|
||||
private static String getBindAddressInternal(InetSocketAddress address) {
|
||||
final InetAddress addr = address.getAddress();
|
||||
if (addr != null) {
|
||||
return addr.getHostAddress();
|
||||
} else {
|
||||
LogFactory.getLog(HServerAddress.class).error("Could not resolve the"
|
||||
+ " DNS name of " + address.getHostName());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBindAddressCanBeResolved() {
|
||||
if (getBindAddress() == null) {
|
||||
throw new IllegalArgumentException("Could not resolve the"
|
||||
|
@ -155,7 +167,7 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
|
|||
String hostname = in.readUTF();
|
||||
int port = in.readInt();
|
||||
if (hostname != null && hostname.length() > 0) {
|
||||
this.address = new InetSocketAddress(hostname, port);
|
||||
this.address = getResolvedAddress(new InetSocketAddress(hostname, port));
|
||||
checkBindAddressCanBeResolved();
|
||||
createCachedToString();
|
||||
}
|
||||
|
@ -182,4 +194,4 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
|
|||
if (this.address.equals(o.address)) return 0;
|
||||
return toString().compareTo(o.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue