FAQ
Author: vgumashta
Date: Sat Nov 8 19:18:01 2014
New Revision: 1637588

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

Modified:
     hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
     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/auth/HiveAuthFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java?rev=1637588&r1=1637587&r2=1637588&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java Sat Nov 8 19:18:01 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/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=1637588&r1=1637587&r2=1637588&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 Sat Nov 8 19:18:01 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/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=1637588&r1=1637587&r2=1637588&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 Sat Nov 8 19:18:01 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();
    }

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedNov 8, '14 at 7:19p
activeNov 8, '14 at 7:19p
posts1
users1
websitehive.apache.org

1 user in discussion

Vgumashta: 1 post

People

Translate

site design / logo © 2021 Grokbase