Repository: hive Updated Branches: refs/heads/master 5b2124b99 -> e9e1f8f6e
HIVE-20130: Better logging for information schema synchronizer (Daniel Dai, reviewed by Vaibhav Gumashta) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e9e1f8f6 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e9e1f8f6 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e9e1f8f6 Branch: refs/heads/master Commit: e9e1f8f6e2f7b66585dc58ca561002b4bdee87fa Parents: 5b2124b Author: Daniel Dai <dai...@gmail.com> Authored: Tue Jul 31 16:54:26 2018 -0700 Committer: Daniel Dai <dai...@gmail.com> Committed: Tue Jul 31 16:54:30 2018 -0700 ---------------------------------------------------------------------- .../authorization/PrivilegeSynchonizer.java | 17 ++++++++++++----- .../apache/hive/service/server/HiveServer2.java | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/e9e1f8f6/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/PrivilegeSynchonizer.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/PrivilegeSynchonizer.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/PrivilegeSynchonizer.java index e56094e..9ce665f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/PrivilegeSynchonizer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/PrivilegeSynchonizer.java @@ -166,19 +166,25 @@ public class PrivilegeSynchonizer implements Runnable { long interval = HiveConf.getTimeVar(hiveConf, ConfVars.HIVE_PRIVILEGE_SYNCHRONIZER_INTERVAL, TimeUnit.SECONDS); try { for (HivePolicyProvider policyProvider : policyProviderContainer) { + LOG.info("Start synchronize privilege " + policyProvider.getClass().getName()); String authorizer = policyProvider.getClass().getSimpleName(); if (!privilegeSynchonizerLatch.await(interval, TimeUnit.SECONDS)) { + LOG.info("Not selected as leader, skip"); continue; } - LOG.info("Start synchonize privilege"); + int numDb = 0, numTbl = 0; for (String dbName : hiveClient.getAllDatabases()) { + numDb++; HiveObjectRef dbToRefresh = getObjToRefresh(HiveObjectType.DATABASE, dbName, null); PrivilegeBag grantDatabaseBag = new PrivilegeBag(); addGrantPrivilegesToBag(policyProvider, grantDatabaseBag, HiveObjectType.DATABASE, dbName, null, null, authorizer); hiveClient.refresh_privileges(dbToRefresh, authorizer, grantDatabaseBag); + LOG.debug("processing " + dbName); for (String tblName : hiveClient.getAllTables(dbName)) { + numTbl++; + LOG.debug("processing " + dbName + "." + tblName); HiveObjectRef tableToRefresh = getObjToRefresh(HiveObjectType.TABLE, dbName, tblName); PrivilegeBag grantTableBag = new PrivilegeBag(); addGrantPrivilegesToBag(policyProvider, grantTableBag, HiveObjectType.TABLE, @@ -199,13 +205,14 @@ public class PrivilegeSynchonizer implements Runnable { hiveClient.refresh_privileges(tableOfColumnsToRefresh, authorizer, grantColumnBag); } } - // Wait if no exception happens, otherwise, retry immediately + LOG.info("Success synchronize privilege " + policyProvider.getClass().getName() + ":" + numDb + " databases, " + + numTbl + " tables"); } + // Wait if no exception happens, otherwise, retry immediately + LOG.info("Wait for " + interval + " seconds"); Thread.sleep(interval * 1000); - LOG.info("Success synchonize privilege"); - } catch (Exception e) { - LOG.error("Error initializing PrivilegeSynchonizer: " + e.getMessage(), e); + LOG.error("Error initializing PrivilegeSynchronizer: " + e.getMessage(), e); } } } http://git-wip-us.apache.org/repos/asf/hive/blob/e9e1f8f6/service/src/java/org/apache/hive/service/server/HiveServer2.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java index ded3670..1f6a097 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -1011,6 +1011,7 @@ public class HiveServer2 extends CompositeService { + ZooKeeperHiveHelper.ZOOKEEPER_PATH_SEPARATOR + "leader"; LeaderLatch privilegeSynchonizerLatch = new LeaderLatch(zKClientForPrivSync, path); privilegeSynchonizerLatch.start(); + LOG.info("Find " + policyContainer.size() + " policy to synchronize, start PrivilegeSynchonizer"); Thread privilegeSynchonizerThread = new Thread( new PrivilegeSynchonizer(privilegeSynchonizerLatch, policyContainer, hiveConf), "PrivilegeSynchonizer"); privilegeSynchonizerThread.start();