hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [18/44] hive git commit: HIVE-14820: RPC server for spark inside HS2 is not getting server address properly (Aihua Xu, reviewed by Yongzhi Chen)
Date Sat, 01 Oct 2016 01:09:00 GMT
HIVE-14820: RPC server for spark inside HS2 is not getting server address properly (Aihua Xu,
reviewed by Yongzhi Chen)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/421d97a8
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/421d97a8
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/421d97a8

Branch: refs/heads/hive-14535
Commit: 421d97a8d75490ca8ec698ef67f7ed8739e394f8
Parents: f284b6d
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Thu Sep 22 15:46:21 2016 -0400
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Fri Sep 23 09:15:36 2016 -0400

----------------------------------------------------------------------
 .../hive/spark/client/rpc/RpcConfiguration.java |  4 +--
 .../apache/hive/spark/client/rpc/TestRpc.java   | 29 +++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/421d97a8/spark-client/src/main/java/org/apache/hive/spark/client/rpc/RpcConfiguration.java
----------------------------------------------------------------------
diff --git a/spark-client/src/main/java/org/apache/hive/spark/client/rpc/RpcConfiguration.java
b/spark-client/src/main/java/org/apache/hive/spark/client/rpc/RpcConfiguration.java
index e387659..210f8a4 100644
--- a/spark-client/src/main/java/org/apache/hive/spark/client/rpc/RpcConfiguration.java
+++ b/spark-client/src/main/java/org/apache/hive/spark/client/rpc/RpcConfiguration.java
@@ -97,11 +97,11 @@ public final class RpcConfiguration {
    * @throws IOException
    */
   String getServerAddress() throws IOException {
-    String hiveHost = config.get(HiveConf.ConfVars.SPARK_RPC_SERVER_ADDRESS);
+    String hiveHost = config.get(HiveConf.ConfVars.SPARK_RPC_SERVER_ADDRESS.varname);
     if(StringUtils.isEmpty(hiveHost)) {
       hiveHost = System.getenv("HIVE_SERVER2_THRIFT_BIND_HOST");
       if (hiveHost == null) {
-        hiveHost = config.get(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST);
+        hiveHost = config.get(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST.varname);
       }
     }
     return ServerUtils.getHostAddress(hiveHost).getHostName();

http://git-wip-us.apache.org/repos/asf/hive/blob/421d97a8/spark-client/src/test/java/org/apache/hive/spark/client/rpc/TestRpc.java
----------------------------------------------------------------------
diff --git a/spark-client/src/test/java/org/apache/hive/spark/client/rpc/TestRpc.java b/spark-client/src/test/java/org/apache/hive/spark/client/rpc/TestRpc.java
index d7969c9..7bcf1df 100644
--- a/spark-client/src/test/java/org/apache/hive/spark/client/rpc/TestRpc.java
+++ b/spark-client/src/test/java/org/apache/hive/spark/client/rpc/TestRpc.java
@@ -18,26 +18,30 @@
 package org.apache.hive.spark.client.rpc;
 
 import java.io.Closeable;
+import java.net.InetAddress;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.security.sasl.SaslException;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
+
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.embedded.EmbeddedChannel;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.util.concurrent.Future;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -117,6 +121,29 @@ public class TestRpc {
   }
 
   @Test
+  public void testServerAddress() throws Exception {
+    String hostAddress = InetAddress.getLocalHost().getHostName();
+    Map<String, String> config = new HashMap<String, String>();
+
+    // Test if rpc_server_address is configured
+    config.put(HiveConf.ConfVars.SPARK_RPC_SERVER_ADDRESS.varname, hostAddress);
+    RpcServer server1 = autoClose(new RpcServer(config));
+    assertTrue("Host address should match the expected one", server1.getAddress() == hostAddress);
+
+    // Test if rpc_server_address is not configured but HS2 server host is configured
+    config.put(HiveConf.ConfVars.SPARK_RPC_SERVER_ADDRESS.varname, "");
+    config.put(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST.varname, hostAddress);
+    RpcServer server2 = autoClose(new RpcServer(config));
+    assertTrue("Host address should match the expected one", server2.getAddress() == hostAddress);
+
+    // Test if both are not configured
+    config.put(HiveConf.ConfVars.SPARK_RPC_SERVER_ADDRESS.varname, "");
+    config.put(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST.varname, "");
+    RpcServer server3 = autoClose(new RpcServer(config));
+    assertTrue("Host address should match the expected one", server3.getAddress() == InetAddress.getLocalHost().getHostName());
+  }
+
+  @Test
   public void testBadHello() throws Exception {
     RpcServer server = autoClose(new RpcServer(emptyConfig));
 


Mime
View raw message