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:
Zhihong Yu 2011-07-07 16:44:49 +00:00
parent 3c3169bf0c
commit 1e90b73574
2 changed files with 24 additions and 10 deletions

View File

@ -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)

View File

@ -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,20 +80,32 @@ 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();
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 " + this.address.toString());
+ " DNS name of " + address.getHostName());
return null;
}
}
private void checkBindAddressCanBeResolved() {
if (getBindAddress() == null) {
@ -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();
}