diff --git llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java index 35ed40c240..ad39963614 100644 --- llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java +++ llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java @@ -395,6 +395,14 @@ public void onRemoval(RemovalNotification arg) { this.token = token; if (token != null) { String tokenUser = getTokenUser(token); + if (tokenUser == null) { + try { + tokenUser = UserGroupInformation.getCurrentUser().getShortUserName(); + } catch (IOException e) { + throw new RuntimeException(e); + } + LOG.warn("Cannot determine token user from the token; using {}", tokenUser); + } this.tokenUser = tokenUser; } else { this.tokenUser = null; @@ -436,13 +444,16 @@ public ProtocolType call() throws Exception { private ProtocolType createProxy( final LlapNodeId nodeId, Token nodeToken) throws IOException { - if (nodeToken == null && token == null) { + if (nodeToken == null && this.token == null) { if (LOG.isDebugEnabled()) { LOG.debug("Creating a client without a token for " + nodeId); } return createProtocolImpl(getConfig(), nodeId.getHostname(), nodeId.getPort(), null, retryPolicy, socketFactory); } + if (this.token != null && this.tokenUser == null) { + throw new AssertionError("Invalid internal state from " + this.token); + } // Either the token should be passed in here, or in ctor. String tokenUser = this.tokenUser == null ? getTokenUser(nodeToken) : this.tokenUser; if (tokenUser == null) { diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java index 6cb1db25a2..615c5a47e1 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java @@ -41,10 +41,13 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.token.Token; import org.apache.tez.common.security.JobTokenIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LlapPluginEndpointClientImpl extends AsyncPbRpcProxy implements LlapPluginEndpointClient { + private static final Logger LOG = LoggerFactory.getLogger(LlapPluginEndpointClientImpl.class); public LlapPluginEndpointClientImpl( Configuration conf, Token token, int expectedNodes) { @@ -74,7 +77,16 @@ protected void shutdownProtocolImpl(LlapPluginProtocolPB proxy) { @Override protected String getTokenUser(Token token) { try { - return token.decodeIdentifier().getJobId().toString(); + JobTokenIdentifier id = token.decodeIdentifier(); + if (id == null) { + LOG.warn("Token ID is null from " + token); + return null; + } + if (id.getJobId() == null) { + LOG.warn("Job ID is null from " + id); + return null; + } + return id.getJobId().toString(); } catch (IOException e) { throw new RuntimeException(e); }