sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amis...@apache.org
Subject [sentry] branch master updated: SENTRY-2477: When requesting for deltas check if nn seq num is 1 more than latest sequence num (Arjun Mishra reviewed by Na Li)
Date Wed, 06 Feb 2019 19:05:15 GMT
This is an automated email from the ASF dual-hosted git repository.

amishra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sentry.git


The following commit(s) were added to refs/heads/master by this push:
     new 3edbd2e  SENTRY-2477: When requesting for deltas check if nn seq num is 1 more than
latest sequence num (Arjun Mishra reviewed by Na Li)
3edbd2e is described below

commit 3edbd2e8c239e6eb148722043033202346bbe66e
Author: amishra <amishra@cloudera.com>
AuthorDate: Wed Feb 6 13:05:02 2019 -0600

    SENTRY-2477: When requesting for deltas check if nn seq num is 1 more than latest sequence
num (Arjun Mishra reviewed by Na Li)
---
 .../org/apache/sentry/hdfs/DBUpdateForwarder.java  |  2 +-
 .../apache/sentry/hdfs/TestDBUpdateForwarder.java  | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java
b/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java
index 08b16a4..67fece1 100644
--- a/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java
+++ b/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java
@@ -117,7 +117,7 @@ class DBUpdateForwarder<K extends Updateable.Update> {
     long curSeqNum = deltaRetriever.getLatestDeltaID();
     LOGGER.debug("({}) Current sequence number is {}", retrieverType, curSeqNum);
 
-    if (seqNum > curSeqNum) {
+    if (seqNum == curSeqNum + 1) {
       // No new notifications were processed.
       LOGGER.debug("{}, No new updates", retrieverType);
       return Collections.emptyList();
diff --git a/sentry-hdfs/sentry-hdfs-service/src/test/java/org/apache/sentry/hdfs/TestDBUpdateForwarder.java
b/sentry-hdfs/sentry-hdfs-service/src/test/java/org/apache/sentry/hdfs/TestDBUpdateForwarder.java
index f86ce6f..35cfb63 100644
--- a/sentry-hdfs/sentry-hdfs-service/src/test/java/org/apache/sentry/hdfs/TestDBUpdateForwarder.java
+++ b/sentry-hdfs/sentry-hdfs-service/src/test/java/org/apache/sentry/hdfs/TestDBUpdateForwarder.java
@@ -92,6 +92,15 @@ public class TestDBUpdateForwarder {
   }
 
   @Test
+  public void testEmptyListReturnedWhenImageSeqIsEqualToLatest() throws Exception {
+    Mockito.when(imageRetriever.getLatestImageID()).thenReturn(1L);
+    Mockito.when(deltaRetriever.getLatestDeltaID()).thenReturn(10L);
+
+    List<PathsUpdate> updates = updater.getAllUpdatesFrom(11, 1);
+    assertTrue(updates.isEmpty());
+  }
+
+  @Test
   public void testFirstImageSyncIsReturnedWhenImageNumIsZero() throws Exception {
     Mockito.when(imageRetriever.getLatestImageID()).thenReturn(1L);
     Mockito.when(imageRetriever.retrieveFullImage())
@@ -143,6 +152,21 @@ public class TestDBUpdateForwarder {
   }
 
   @Test
+  public void testNewImageUpdateIsReturnedWhenImageSeqIsGreaterThanLatestSeqByOne() throws
Exception {
+    Mockito.when(imageRetriever.getLatestImageID()).thenReturn(1L);
+    Mockito.when(deltaRetriever.getLatestDeltaID()).thenReturn(10L);
+    Mockito.when(deltaRetriever.isDeltaAvailable(15)).thenReturn(false);
+    Mockito.when(imageRetriever.retrieveFullImage())
+        .thenReturn(new PathsUpdate(10, 1, true));
+
+    List<PathsUpdate> updates = updater.getAllUpdatesFrom(15, 1);
+    assertEquals(1, updates.size());
+    assertEquals(10, updates.get(0).getSeqNum());
+    assertEquals(1, updates.get(0).getImgNum());
+    assertTrue(updates.get(0).hasFullImage());
+  }
+
+  @Test
   public void testNewImageUpdateIsReturnedWhenRequestedDeltaIsNotAvailable() throws Exception
{
     Mockito.when(imageRetriever.getLatestImageID()).thenReturn(1L);
     Mockito.when(deltaRetriever.getLatestDeltaID()).thenReturn(3L);


Mime
View raw message