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 7a098d4 HIVE-21970: Avoid using RegistryUtils.currentUser() (Prasanth
Jayachandran reviewed by Gopal V)
7a098d4 is described below
commit 7a098d49a3fb174e5bfd9ebe15e1cd041323cfa9
Author: Prasanth Jayachandran <[email protected]>
AuthorDate: Mon Jul 29 14:13:16 2019 -0700
HIVE-21970: Avoid using RegistryUtils.currentUser() (Prasanth Jayachandran
reviewed by Gopal V)
---
.../hadoop/hive/llap/registry/impl/LlapRegistryService.java | 7 ++++++-
.../hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java | 4 ++--
.../org/apache/hadoop/hive/registry/impl/TezAmRegistryImpl.java | 3 ++-
.../java/org/apache/hadoop/hive/registry/impl/ZkRegistryBase.java | 8 ++++++++
.../apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java | 3 ++-
.../apache/hive/service/server/HS2ActivePassiveHARegistry.java | 4 ++--
6 files changed, 22 insertions(+), 7 deletions(-)
diff --git
a/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapRegistryService.java
b/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapRegistryService.java
index 2d05bda..9a64be0 100644
---
a/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapRegistryService.java
+++
b/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapRegistryService.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.hive.llap.registry.ServiceRegistry;
import
org.apache.hadoop.hive.llap.registry.impl.LlapZookeeperRegistryImpl.ConfigChangeLockResult;
import org.apache.hadoop.hive.registry.ServiceInstanceStateChangeListener;
import org.apache.hadoop.registry.client.binding.RegistryUtils;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.AbstractService;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.slf4j.Logger;
@@ -92,7 +93,11 @@ public class LlapRegistryService extends AbstractService {
}
public static String currentUser() {
- return RegistryUtils.currentUser();
+ try {
+ return UserGroupInformation.getCurrentUser().getShortUserName();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
diff --git
a/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java
b/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java
index 9e1da9b..92c4771 100644
---
a/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java
+++
b/llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java
@@ -447,8 +447,8 @@ public class LlapZookeeperRegistryImpl
@Override
protected String getZkPathUser(Configuration conf) {
// External LLAP clients would need to set LLAP_ZK_REGISTRY_USER to the
LLAP daemon user (hive),
- // rather than relying on RegistryUtils.currentUser().
- return HiveConf.getVar(conf, ConfVars.LLAP_ZK_REGISTRY_USER,
RegistryUtils.currentUser());
+ // rather than relying on LlapRegistryService.currentUser().
+ return HiveConf.getVar(conf, ConfVars.LLAP_ZK_REGISTRY_USER,
LlapRegistryService.currentUser());
}
/**
diff --git
a/llap-client/src/java/org/apache/hadoop/hive/registry/impl/TezAmRegistryImpl.java
b/llap-client/src/java/org/apache/hadoop/hive/registry/impl/TezAmRegistryImpl.java
index 3ff732d..754e803 100644
---
a/llap-client/src/java/org/apache/hadoop/hive/registry/impl/TezAmRegistryImpl.java
+++
b/llap-client/src/java/org/apache/hadoop/hive/registry/impl/TezAmRegistryImpl.java
@@ -23,6 +23,7 @@ import
org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
+import org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService;
import org.apache.hadoop.registry.client.binding.RegistryTypeUtils;
import org.apache.hadoop.registry.client.binding.RegistryUtils;
import org.apache.hadoop.registry.client.types.Endpoint;
@@ -118,7 +119,7 @@ public class TezAmRegistryImpl extends
ZkRegistryBase<TezAmInstance> {
@Override
protected String getZkPathUser(Configuration conf) {
// We assume that AMs and HS2 run under the same user.
- return RegistryUtils.currentUser();
+ return LlapRegistryService.currentUser();
}
public String getRegistryName() {
diff --git
a/llap-client/src/java/org/apache/hadoop/hive/registry/impl/ZkRegistryBase.java
b/llap-client/src/java/org/apache/hadoop/hive/registry/impl/ZkRegistryBase.java
index 7ca3548..e56ae11 100644
---
a/llap-client/src/java/org/apache/hadoop/hive/registry/impl/ZkRegistryBase.java
+++
b/llap-client/src/java/org/apache/hadoop/hive/registry/impl/ZkRegistryBase.java
@@ -669,4 +669,12 @@ public abstract class ZkRegistryBase<InstanceType extends
ServiceInstance> {
LOG.info("Connection state change notification received. State: {}",
connectionState);
}
}
+
+ public String currentUser() {
+ try {
+ return UserGroupInformation.getCurrentUser().getShortUserName();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
index c925a3f..5c760e8 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
@@ -52,6 +52,7 @@ import org.apache.hadoop.hive.llap.SubmitWorkInfo;
import org.apache.hadoop.hive.llap.coordinator.LlapCoordinator;
import
org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.QueryIdentifierProto;
import
org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SignableVertexSpec;
+import org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService;
import org.apache.hadoop.hive.llap.security.LlapSigner;
import org.apache.hadoop.hive.llap.security.LlapSigner.Signable;
import org.apache.hadoop.hive.llap.security.LlapSigner.SignedMessage;
@@ -442,7 +443,7 @@ public class GenericUDTFGetSplits extends GenericUDTF {
}
// This assumes LLAP cluster owner is always the HS2 user.
- String llapUser = RegistryUtils.currentUser();
+ String llapUser = LlapRegistryService.currentUser();
String queryUser = null;
byte[] tokenBytes = null;
diff --git
a/service/src/java/org/apache/hive/service/server/HS2ActivePassiveHARegistry.java
b/service/src/java/org/apache/hive/service/server/HS2ActivePassiveHARegistry.java
index ea5965d..95c1388 100644
---
a/service/src/java/org/apache/hive/service/server/HS2ActivePassiveHARegistry.java
+++
b/service/src/java/org/apache/hive/service/server/HS2ActivePassiveHARegistry.java
@@ -40,9 +40,9 @@ import org.apache.hadoop.hive.registry.ServiceInstanceSet;
import org.apache.hadoop.hive.registry.ServiceInstanceStateChangeListener;
import org.apache.hadoop.hive.registry.impl.ZkRegistryBase;
import org.apache.hadoop.registry.client.binding.RegistryTypeUtils;
-import org.apache.hadoop.registry.client.binding.RegistryUtils;
import org.apache.hadoop.registry.client.types.Endpoint;
import org.apache.hadoop.registry.client.types.ServiceRecord;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hive.service.ServiceException;
import org.slf4j.Logger;
@@ -206,7 +206,7 @@ public class HS2ActivePassiveHARegistry extends
ZkRegistryBase<HiveServer2Instan
@Override
protected String getZkPathUser(final Configuration conf) {
- return RegistryUtils.currentUser();
+ return currentUser();
}
private boolean hasLeadership() {