You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/08/02 22:33:44 UTC

[2/5] git commit: ACCUMULO-1585 do our best to guess our address after the bind

ACCUMULO-1585 do our best to guess our address after the bind


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/9d50657d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/9d50657d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/9d50657d

Branch: refs/heads/master
Commit: 9d50657d90a4450604b7c64ba1870cfc0f8b1a3a
Parents: af6c7e8
Author: Eric Newton <er...@gmail.com>
Authored: Fri Aug 2 16:25:22 2013 -0400
Committer: Eric Newton <er...@gmail.com>
Committed: Fri Aug 2 16:25:22 2013 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/server/util/TServerUtils.java     | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/9d50657d/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java b/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
index 926e370..0c56476 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.server.util;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -216,6 +217,15 @@ public class TServerUtils {
   public static ServerAddress startHsHaServer(InetSocketAddress address, TProcessor processor, final String serverName, String threadName, final int numThreads,
       long timeBetweenThreadChecks, long maxMessageSize) throws TTransportException {
     TNonblockingServerSocket transport = new TNonblockingServerSocket(address);
+    // check for the special "bind to everything address"
+    if (address.getAddress().getHostAddress().equals("0.0.0.0")) {
+      // can't get the address from the bind, so we'll do our best to invent our hostname
+      try {
+        address = new InetSocketAddress(InetAddress.getLocalHost().getHostName(), address.getPort());
+      } catch (UnknownHostException e) {
+        throw new TTransportException(e);
+      }
+    }
     THsHaServer.Args options = new THsHaServer.Args(transport);
     options.protocolFactory(ThriftUtil.protocolFactory());
     options.transportFactory(ThriftUtil.transportFactory(maxMessageSize));