You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2018/04/18 03:28:15 UTC
[2/2] hive git commit: HIVE-19224 : incorrect token handling for LLAP
plugin endpoint - part 2 (Sergey Shelukhin, reviewed by Prasanth Jayachandran)
HIVE-19224 : incorrect token handling for LLAP plugin endpoint - part 2 (Sergey Shelukhin, reviewed by Prasanth Jayachandran)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/db5b7853
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/db5b7853
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/db5b7853
Branch: refs/heads/branch-3
Commit: db5b7853035d994951c7488af93daa8ac95bda1d
Parents: 624e464
Author: sergey <se...@apache.org>
Authored: Tue Apr 17 20:23:13 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Tue Apr 17 20:23:23 2018 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java | 13 ++++++++++++-
.../ql/exec/tez/LlapPluginEndpointClientImpl.java | 14 +++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/db5b7853/llap-common/src/java/org/apache/hadoop/hive/llap/AsyncPbRpcProxy.java
----------------------------------------------------------------------
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 35ed40c..ad39963 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
@@ -395,6 +395,14 @@ public abstract class AsyncPbRpcProxy<ProtocolType, TokenType extends TokenIdent
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 abstract class AsyncPbRpcProxy<ProtocolType, TokenType extends TokenIdent
private ProtocolType createProxy(
final LlapNodeId nodeId, Token<TokenType> 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) {
http://git-wip-us.apache.org/repos/asf/hive/blob/db5b7853/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java
index 6cb1db2..615c5a4 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/LlapPluginEndpointClientImpl.java
@@ -41,10 +41,13 @@ import org.apache.hadoop.io.retry.RetryPolicy;
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<LlapPluginProtocolPB, JobTokenIdentifier>
implements LlapPluginEndpointClient {
+ private static final Logger LOG = LoggerFactory.getLogger(LlapPluginEndpointClientImpl.class);
public LlapPluginEndpointClientImpl(
Configuration conf, Token<JobTokenIdentifier> token, int expectedNodes) {
@@ -74,7 +77,16 @@ public class LlapPluginEndpointClientImpl extends
@Override
protected String getTokenUser(Token<JobTokenIdentifier> 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);
}