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-4061 getTableDirs is missing directories to skip
HBASE-3867 when cluster is stopped and server which hosted meta region is HBASE-3867 when cluster is stopped and server which hosted meta region is
removed from cluster, master breaks down after restarting cluster. 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 IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) 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 * @param port Port number
*/ */
public HServerAddress(final String hostname, final int port) { 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 * @param other HServerAddress to copy from
*/ */
public HServerAddress(HServerAddress other) { 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 /** @return Bind address -- the raw IP, the result of a call to
* {@link InetSocketAddress#getAddress()#getHostAddress()} -- * {@link InetSocketAddress#getAddress()#getHostAddress()} --
* or null if cannot resolve */ * or null if cannot resolve */
public String getBindAddress() { public String getBindAddress() {
// This returns null if the address is not resolved. return getBindAddressInternal(address);
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;
} }
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() { private void checkBindAddressCanBeResolved() {
if (getBindAddress() == null) { if (getBindAddress() == null) {
throw new IllegalArgumentException("Could not resolve the" throw new IllegalArgumentException("Could not resolve the"
@ -155,7 +167,7 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
String hostname = in.readUTF(); String hostname = in.readUTF();
int port = in.readInt(); int port = in.readInt();
if (hostname != null && hostname.length() > 0) { if (hostname != null && hostname.length() > 0) {
this.address = new InetSocketAddress(hostname, port); this.address = getResolvedAddress(new InetSocketAddress(hostname, port));
checkBindAddressCanBeResolved(); checkBindAddressCanBeResolved();
createCachedToString(); createCachedToString();
} }
@ -182,4 +194,4 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
if (this.address.equals(o.address)) return 0; if (this.address.equals(o.address)) return 0;
return toString().compareTo(o.toString()); return toString().compareTo(o.toString());
} }
} }