Skip to content

Commit

Permalink
HIVE-22908: AM caching connections to LLAP based on hostname and port…
Browse files Browse the repository at this point in the history
… does not work in kubernetes (Prasanth Jayachandran reviewed by Gopal Vijayaraghavan)
  • Loading branch information
prasanthj committed Feb 20, 2020
1 parent faaf2c3 commit 703cf29
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -430,6 +432,9 @@ public void onRemoval(RemovalNotification<String, ProtocolType> arg) {
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
Expand Down Expand Up @@ -481,7 +486,16 @@ public ProtocolType run() {
}

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,
Expand Down

0 comments on commit 703cf29

Please sign in to comment.