This is an automated email from the ASF dual-hosted git repository.

prasanthj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 703cf29  HIVE-22908: AM caching connections to LLAP based on hostname 
and port does not work in kubernetes (Prasanth Jayachandran reviewed by Gopal 
Vijayaraghavan)
703cf29 is described below

commit 703cf29fa14fffe7a7e0ee30cd11d16a5245bf1c
Author: Prasanth Jayachandran <prasan...@apache.org>
AuthorDate: Thu Feb 20 14:38:33 2020 -0800

    HIVE-22908: AM caching connections to LLAP based on hostname and port does 
not work in kubernetes (Prasanth Jayachandran reviewed by Gopal Vijayaraghavan)
---
 .../org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java     | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java 
b/llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java
index ad39963..25e10f4 100644
--- a/llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java
+++ b/llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java
@@ -15,6 +15,8 @@
 package org.apache.hadoop.hive.llap;
 
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.security.PrivilegedAction;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -430,6 +432,9 @@ public abstract class AsyncPbRpcProxy<ProtocolType, 
TokenType extends TokenIdent
   protected final ProtocolType getProxy(
       final LlapNodeId nodeId, final Token<TokenType> nodeToken) {
     String hostId = getHostIdentifier(nodeId.getHostname(), nodeId.getPort());
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Getting host proxies for {}", hostId);
+    }
     try {
       return hostProxies.get(hostId, new Callable<ProtocolType>() {
         @Override
@@ -481,7 +486,16 @@ public abstract class AsyncPbRpcProxy<ProtocolType, 
TokenType extends TokenIdent
   }
 
   private String getHostIdentifier(String hostname, int port) {
-    return hostname + ":" + port;
+    StringBuilder sb = new StringBuilder();
+    try {
+      InetAddress inetAddress = InetAddress.getByName(hostname);
+      sb.append(inetAddress.getHostAddress()).append(":");
+    } catch (UnknownHostException e) {
+      // ignore
+      LOG.warn("Unable to determine IP address for host: {}.. Ignoring..", 
hostname, e);
+    }
+    sb.append(hostname).append(":").append(port);
+    return sb.toString();
   }
 
   protected abstract ProtocolType createProtocolImpl(Configuration config, 
String hostname, int port,

Reply via email to