This is an automated email from the ASF dual-hosted git repository. prasanthj pushed a commit to branch branch-3 in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/branch-3 by this push: new a062077 HIVE-21970: Avoid using RegistryUtils.currentUser() (Prasanth Jayachandran reviewed by Gopal V) a062077 is described below commit a062077f6699fc3d8310f64105a7237002dcb9c9 Author: Prasanth Jayachandran <prasan...@apache.org> 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 3bda40b..2289121 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 @@ -27,6 +27,7 @@ import org.apache.hadoop.hive.llap.registry.ServiceRegistry; import org.apache.hadoop.hive.registry.ServiceInstanceSet; 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; @@ -81,7 +82,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 f5d6202..67add92 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 @@ -413,7 +413,7 @@ 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 f4b4362..d52bf63 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; @@ -201,7 +201,7 @@ public class HS2ActivePassiveHARegistry extends ZkRegistryBase<HiveServer2Instan @Override protected String getZkPathUser(final Configuration conf) { - return RegistryUtils.currentUser(); + return currentUser(); } private boolean hasLeadership() {