hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgumas...@apache.org
Subject svn commit: r1636919 - in /hive/trunk/service/src/java/org/apache/hive/service: cli/thrift/ThriftCLIService.java server/HiveServer2.java
Date Wed, 05 Nov 2014 17:27:52 GMT
Author: vgumashta
Date: Wed Nov  5 17:27:52 2014
New Revision: 1636919

URL: http://svn.apache.org/r1636919
Log:
HIVE-8733: HiveServer2 dynamic service discovery not picking correct IP address when hive.server2.thrift.bind.host
is not set (Vaibhav Gumashta reviewed by Thejas Nair)

Modified:
    hive/trunk/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
    hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java

Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java?rev=1636919&r1=1636918&r2=1636919&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java Wed
Nov  5 17:27:52 2014
@@ -19,7 +19,8 @@
 package org.apache.hive.service.cli.thrift;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -31,6 +32,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hive.service.AbstractService;
+import org.apache.hive.service.ServiceException;
 import org.apache.hive.service.auth.HiveAuthFactory;
 import org.apache.hive.service.auth.TSetIpAddressProcessor;
 import org.apache.hive.service.cli.*;
@@ -53,7 +55,7 @@ public abstract class ThriftCLIService e
   protected static HiveAuthFactory hiveAuthFactory;
 
   protected int portNum;
-  protected InetSocketAddress serverAddress;
+  protected InetAddress serverAddress;
   protected String hiveHost;
   protected TServer server;
   protected org.eclipse.jetty.server.Server httpServer;
@@ -75,13 +77,21 @@ public abstract class ThriftCLIService e
   @Override
   public synchronized void init(HiveConf hiveConf) {
     this.hiveConf = hiveConf;
-
     // Initialize common server configs needed in both binary & http modes
     String portString;
     hiveHost = System.getenv("HIVE_SERVER2_THRIFT_BIND_HOST");
     if (hiveHost == null) {
       hiveHost = hiveConf.getVar(ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST);
     }
+    try {
+      if (hiveHost != null && !hiveHost.isEmpty()) {
+        serverAddress = InetAddress.getByName(hiveHost);
+      } else {
+        serverAddress = InetAddress.getLocalHost();
+      }
+    } catch (UnknownHostException e) {
+      throw new ServiceException(e);
+    }
     // HTTP mode
     if (HiveServer2.isHTTPTransportMode(hiveConf)) {
       workerKeepAliveTime =
@@ -105,11 +115,6 @@ public abstract class ThriftCLIService e
         portNum = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_PORT);
       }
     }
-    if (hiveHost != null && !hiveHost.isEmpty()) {
-      serverAddress = new InetSocketAddress(hiveHost, portNum);
-    } else {
-      serverAddress = new InetSocketAddress(portNum);
-    }
     minWorkerThreads = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_MIN_WORKER_THREADS);
     maxWorkerThreads = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_MAX_WORKER_THREADS);
     super.init(hiveConf);
@@ -148,7 +153,7 @@ public abstract class ThriftCLIService e
     return portNum;
   }
 
-  public InetSocketAddress getServerAddress() {
+  public InetAddress getServerAddress() {
     return serverAddress;
   }
 

Modified: hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java?rev=1636919&r1=1636918&r2=1636919&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java Wed Nov  5
17:27:52 2014
@@ -252,7 +252,7 @@ public class HiveServer2 extends Composi
     if ((thriftCLIService == null) || (thriftCLIService.getServerAddress() == null)) {
       throw new Exception("Unable to get the server address; it hasn't been initialized yet.");
     }
-    return thriftCLIService.getServerAddress().getHostName() + ":"
+    return thriftCLIService.getServerAddress().getHostAddress() + ":"
         + thriftCLIService.getPortNumber();
   }
 



Mime
View raw message