sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject sentry git commit: SENTRY-1674: HMSFollower shouldn't print the same value of notification ID multiple times (Na Li, reviewed by Alex Kolbasov, Hao Hao and Kalyan Kalvagadda)
Date Fri, 21 Apr 2017 01:14:09 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 6835fa95b -> d3aeb958a


SENTRY-1674: HMSFollower shouldn't print the same value of notification ID multiple times
(Na Li, reviewed by Alex Kolbasov, Hao Hao and Kalyan Kalvagadda)


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/d3aeb958
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/d3aeb958
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/d3aeb958

Branch: refs/heads/sentry-ha-redesign
Commit: d3aeb958a51c029c5c309768352c5bed3c18fdeb
Parents: 6835fa9
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Thu Apr 20 18:13:35 2017 -0700
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Thu Apr 20 18:13:35 2017 -0700

----------------------------------------------------------------------
 .../apache/sentry/service/thrift/HMSFollower.java | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/d3aeb958/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
index 16676fb..1543379 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/HMSFollower.java
@@ -70,6 +70,8 @@ public class HMSFollower implements Runnable {
   private static final Logger LOGGER = LoggerFactory.getLogger(HMSFollower.class);
 
   private long currentEventID;
+  // Track the latest eventId of the event that has been logged. So we don't log the same
message
+  private long lastLoggedEventId = SentryStore.EMPTY_CHANGE_ID;
   private static boolean connectedToHMS = false;
   private HiveMetaStoreClient client;
   private SentryKerberosContext kerberosContext;
@@ -254,9 +256,17 @@ public class HMSFollower implements Runnable {
 
       NotificationEventResponse response = client.getNextNotification(currentEventID, Integer.MAX_VALUE,
null);
       if (response.isSetEvents()) {
-        LOGGER.info(String.format("CurrentEventID = %s. Processing %s events",
-            currentEventID, response.getEvents().size()));
-        processNotificationEvents(response.getEvents());
+        if (!response.getEvents().isEmpty()) {
+          if (currentEventID != lastLoggedEventId) {
+            // Only log when there are updates and the notification ID has changed.
+            LOGGER.debug(String.format("CurrentEventID = %s. Processing %s events",
+                    currentEventID, response.getEvents().size()));
+
+            lastLoggedEventId = currentEventID;
+          }
+
+          processNotificationEvents(response.getEvents());
+        }
       }
     } catch (TException e) {
       // If the underlying exception is around socket exception, it is better to retry connection
to HMS
@@ -373,7 +383,7 @@ public class HMSFollower implements Runnable {
           dbName = dropDatabaseMessage.getDB();
           if (dbName == null) {
             throw new SentryInvalidHMSEventException(String.format("Drop database event has
incomplete information. " +
-                "dbName = %s", dbName));
+                "dbName = null"));
           }
           if (syncWithPolicyStore(AUTHZ_SYNC_DROP_WITH_POLICY_STORE)) {
             try {


Mime
View raw message