Repository: hive Updated Branches: refs/heads/branch-3 7774508f5 -> bc7570812
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/bc757081 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/bc757081 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/bc757081 Branch: refs/heads/branch-3 Commit: bc75708126a08a345df9abf78f6dbc270ec71c3c Parents: 7774508 Author: Daniel Dai <dai...@gmail.com> Authored: Tue Jul 31 16:55:56 2018 -0700 Committer: Daniel Dai <dai...@gmail.com> Committed: Tue Jul 31 16:55:56 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/bc757081/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/bc757081/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 6184fdc..fe3bf1d 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -1005,6 +1005,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();