hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1143915 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/HServerAddress.java
Date Thu, 07 Jul 2011 16:44:49 GMT
Author: tedyu
Date: Thu Jul  7 16:44:49 2011
New Revision: 1143915

URL: http://svn.apache.org/viewvc?rev=1143915&view=rev
Log:
HBASE-4074  When a RS has hostname with uppercase letter, there are two
               RS entries in master

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1143915&r1=1143914&r2=1143915&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Thu Jul  7 16:44:49 2011
@@ -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)  

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java?rev=1143915&r1=1143914&r2=1143915&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java Thu Jul  7 16:44:49
2011
@@ -72,7 +72,7 @@ public class HServerAddress implements W
    * @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 W
    * @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 W
     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 W
     if (this.address.equals(o.address)) return 0;
     return toString().compareTo(o.toString());
   }
-}
\ No newline at end of file
+}



Mime
View raw message