You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ha...@apache.org on 2017/08/18 20:55:14 UTC

sentry git commit: SENTRY-1890: HMSFollower keep getting full snapshot when HDFS is disabled. (Na Li, Reviewed by: Vamsee Yarlagadda)

Repository: sentry
Updated Branches:
  refs/heads/master 2fa149d19 -> 5eae90ea9


SENTRY-1890: HMSFollower keep getting full snapshot when HDFS is disabled. (Na Li, Reviewed by: Vamsee Yarlagadda)

Change-Id: I10a4723edda0bb952129dbc4229c955fc96e5ada


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

Branch: refs/heads/master
Commit: 5eae90ea99d7c43da2974c11549967bfa89f117a
Parents: 2fa149d
Author: hahao <ha...@cloudera.com>
Authored: Fri Aug 18 13:52:42 2017 -0700
Committer: hahao <ha...@cloudera.com>
Committed: Fri Aug 18 13:52:42 2017 -0700

----------------------------------------------------------------------
 .../db/service/persistent/SentryStore.java         | 17 ++++++++---------
 .../apache/sentry/service/thrift/HMSFollower.java  |  2 +-
 .../db/service/persistent/TestSentryStore.java     |  2 +-
 .../sentry/service/thrift/TestHMSFollower.java     |  6 +++++-
 4 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/5eae90ea/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index e9de73a..d7acaea 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -3026,19 +3026,18 @@ public class SentryStore {
   /**
    * Tells if there are any records in MSentryHmsNotification
    *
-   * @return true if there are no entries in {@link MSentryHmsNotification}
+   * @return true if there are no entries in <code>MSentryHmsNotification</code>
    * false if there are entries
    * @throws Exception
    */
-  @VisibleForTesting
-  boolean isNotificationIDTableEmpty() throws Exception {
+  public boolean isHmsNotificationEmpty() throws Exception {
     return tm.executeTransactionWithRetry(
-      new TransactionBlock<Boolean>() {
-        public Boolean execute(PersistenceManager pm) throws Exception {
-          pm.setDetachAllOnCommit(false); // No need to detach objects
-          return isTableEmptyCore(pm, MSentryHmsNotification.class);
-        }
-      });
+        new TransactionBlock<Boolean>() {
+          public Boolean execute(PersistenceManager pm) throws Exception {
+            pm.setDetachAllOnCommit(false); // No need to detach objects
+            return isTableEmptyCore(pm, MSentryHmsNotification.class);
+          }
+        });
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/sentry/blob/5eae90ea/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 1d8200d..35da6fc 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
@@ -210,7 +210,7 @@ public class HMSFollower implements Runnable, AutoCloseable {
    * @throws Exception If an error occurs while checking the SentryStore or the HMS client.
    */
   private boolean isFullSnapshotRequired(long latestSentryNotificationId) throws Exception {
-    if (sentryStore.isAuthzPathsMappingEmpty()) {
+    if (sentryStore.isHmsNotificationEmpty()) {
       return true;
     }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/5eae90ea/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
index 2d6b92a..8f60b58 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
@@ -3162,7 +3162,7 @@ public class TestSentryStore extends org.junit.Assert {
 
     int totalentires = 200;
     int remainingEntires = ServerConfig.SENTRY_HMS_NOTIFICATION_ID_KEEP_COUNT_DEFAULT;
-    assertTrue(sentryStore.isNotificationIDTableEmpty());
+    assertTrue(sentryStore.isHmsNotificationEmpty());
     for(int id = 1; id <= totalentires; id++) {
       sentryStore.persistLastProcessedNotificationID((long)id);
     }

http://git-wip-us.apache.org/repos/asf/sentry/blob/5eae90ea/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestHMSFollower.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestHMSFollower.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestHMSFollower.java
index 48b009f..c5fedfc 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestHMSFollower.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestHMSFollower.java
@@ -102,6 +102,7 @@ public class TestHMSFollower {
     // 1st run should get a full snapshot because AuthzPathsMapping is empty
     when(sentryStore.getLastProcessedNotificationID()).thenReturn(SENTRY_PROCESSED_EVENT_ID);
     when(sentryStore.isAuthzPathsMappingEmpty()).thenReturn(true);
+    when(sentryStore.isHmsNotificationEmpty()).thenReturn(true);
     hmsFollower.run();
     verify(sentryStore, times(1)).persistFullPathsImage(
         fullSnapshot.getPathImage(), fullSnapshot.getId());
@@ -781,10 +782,13 @@ public class TestHMSFollower {
 
     // 1st run should get a full snapshot because AuthzPathsMapping is empty
     when(sentryStore.getLastProcessedNotificationID()).thenReturn(SENTRY_PROCESSED_EVENT_ID);
-    when(sentryStore.isAuthzPathsMappingEmpty()).thenReturn(true);
+    when(sentryStore.isAuthzPathsMappingEmpty()).thenReturn(false);
+    when(sentryStore.isHmsNotificationEmpty()).thenReturn(true);
     hmsFollower.run();
     verify(sentryStore, times(0)).persistFullPathsImage(fullSnapshot.getPathImage(), fullSnapshot.getId());
     verify(sentryStore, times(1)).persistLastProcessedNotificationID(fullSnapshot.getId());
+    verify(sentryStore, times(1)).isHmsNotificationEmpty();
+    verify(sentryStore, times(0)).isAuthzPathsMappingEmpty();
   }
 
   @Test