You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vg...@apache.org on 2014/11/08 20:19:05 UTC

svn commit: r1637589 - in /hive/branches/branch-0.14/service/src/java/org/apache/hive/service: auth/HiveAuthFactory.java cli/thrift/ThriftCLIService.java server/HiveServer2.java

Author: vgumashta
Date: Sat Nov  8 19:19:05 2014
New Revision: 1637589

URL: http://svn.apache.org/r1637589
Log:
HIVE-8764: Windows: HiveServer2 TCP SSL cannot recognize localhost (Vaibhav Gumashta reviewed by Thejas Nair)

Modified:
    hive/branches/branch-0.14/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
    hive/branches/branch-0.14/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
    hive/branches/branch-0.14/service/src/java/org/apache/hive/service/server/HiveServer2.java

Modified: hive/branches/branch-0.14/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java?rev=1637589&r1=1637588&r2=1637589&view=diff
==============================================================================
--- hive/branches/branch-0.14/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java (original)
+++ hive/branches/branch-0.14/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java Sat Nov  8 19:19:05 2014
@@ -218,6 +218,7 @@ public class HiveAuthFactory {
     throws TTransportException {
     InetSocketAddress serverAddress;
     if (hiveHost == null || hiveHost.isEmpty()) {
+      // Wildcard bind
       serverAddress = new InetSocketAddress(portNum);
     } else {
       serverAddress = new InetSocketAddress(hiveHost, portNum);
@@ -226,25 +227,26 @@ public class HiveAuthFactory {
   }
 
   public static TServerSocket getServerSSLSocket(String hiveHost, int portNum, String keyStorePath,
-    String keyStorePassWord,  List<String> sslVersionBlacklist)
-      throws TTransportException, UnknownHostException {
+      String keyStorePassWord, List<String> sslVersionBlacklist) throws TTransportException,
+      UnknownHostException {
     TSSLTransportFactory.TSSLTransportParameters params =
-      new TSSLTransportFactory.TSSLTransportParameters();
+        new TSSLTransportFactory.TSSLTransportParameters();
     params.setKeyStore(keyStorePath, keyStorePassWord);
-
-    InetAddress serverAddress;
+    InetSocketAddress serverAddress;
     if (hiveHost == null || hiveHost.isEmpty()) {
-      serverAddress = InetAddress.getLocalHost();
+      // Wildcard bind
+      serverAddress = new InetSocketAddress(portNum);
     } else {
-      serverAddress = InetAddress.getByName(hiveHost);
+      serverAddress = new InetSocketAddress(hiveHost, portNum);
     }
-    TServerSocket thriftServerSocket = TSSLTransportFactory.getServerSocket(portNum, 0, serverAddress, params);
+    TServerSocket thriftServerSocket =
+        TSSLTransportFactory.getServerSocket(portNum, 0, serverAddress.getAddress(), params);
     if (thriftServerSocket.getServerSocket() instanceof SSLServerSocket) {
       List<String> sslVersionBlacklistLocal = new ArrayList<String>();
       for (String sslVersion : sslVersionBlacklist) {
         sslVersionBlacklistLocal.add(sslVersion.trim().toLowerCase());
       }
-      SSLServerSocket sslServerSocket = (SSLServerSocket)thriftServerSocket.getServerSocket();
+      SSLServerSocket sslServerSocket = (SSLServerSocket) thriftServerSocket.getServerSocket();
       List<String> enabledProtocols = new ArrayList<String>();
       for (String protocol : sslServerSocket.getEnabledProtocols()) {
         if (sslVersionBlacklistLocal.contains(protocol.toLowerCase())) {
@@ -254,7 +256,8 @@ public class HiveAuthFactory {
         }
       }
       sslServerSocket.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
-      LOG.info("SSL Server Socket Enabled Protocols: " + Arrays.toString(sslServerSocket.getEnabledProtocols()));
+      LOG.info("SSL Server Socket Enabled Protocols: "
+          + Arrays.toString(sslServerSocket.getEnabledProtocols()));
     }
     return thriftServerSocket;
   }

Modified: hive/branches/branch-0.14/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java?rev=1637589&r1=1637588&r2=1637589&view=diff
==============================================================================
--- hive/branches/branch-0.14/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java (original)
+++ hive/branches/branch-0.14/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java Sat Nov  8 19:19:05 2014
@@ -55,7 +55,7 @@ public abstract class ThriftCLIService e
   protected static HiveAuthFactory hiveAuthFactory;
 
   protected int portNum;
-  protected InetAddress serverAddress;
+  protected InetAddress serverIPAddress;
   protected String hiveHost;
   protected TServer server;
   protected org.eclipse.jetty.server.Server httpServer;
@@ -85,9 +85,9 @@ public abstract class ThriftCLIService e
     }
     try {
       if (hiveHost != null && !hiveHost.isEmpty()) {
-        serverAddress = InetAddress.getByName(hiveHost);
+        serverIPAddress = InetAddress.getByName(hiveHost);
       } else {
-        serverAddress = InetAddress.getLocalHost();
+        serverIPAddress = InetAddress.getLocalHost();
       }
     } catch (UnknownHostException e) {
       throw new ServiceException(e);
@@ -153,8 +153,8 @@ public abstract class ThriftCLIService e
     return portNum;
   }
 
-  public InetAddress getServerAddress() {
-    return serverAddress;
+  public InetAddress getServerIPAddress() {
+    return serverIPAddress;
   }
 
   @Override

Modified: hive/branches/branch-0.14/service/src/java/org/apache/hive/service/server/HiveServer2.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/service/src/java/org/apache/hive/service/server/HiveServer2.java?rev=1637589&r1=1637588&r2=1637589&view=diff
==============================================================================
--- hive/branches/branch-0.14/service/src/java/org/apache/hive/service/server/HiveServer2.java (original)
+++ hive/branches/branch-0.14/service/src/java/org/apache/hive/service/server/HiveServer2.java Sat Nov  8 19:19:05 2014
@@ -249,10 +249,10 @@ public class HiveServer2 extends Composi
   }
 
   private String getServerInstanceURI(HiveConf hiveConf) throws Exception {
-    if ((thriftCLIService == null) || (thriftCLIService.getServerAddress() == null)) {
+    if ((thriftCLIService == null) || (thriftCLIService.getServerIPAddress() == null)) {
       throw new Exception("Unable to get the server address; it hasn't been initialized yet.");
     }
-    return thriftCLIService.getServerAddress().getHostName() + ":"
+    return thriftCLIService.getServerIPAddress().getHostName() + ":"
         + thriftCLIService.getPortNumber();
   }