bgaborg commented on a change in pull request #802: HADOOP-16279. S3Guard:
Implement time-based (TTL) expiry for entries …
URL: https://github.com/apache/hadoop/pull/802#discussion_r291526606
##########
File path:
hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/MetadataStoreTestBase.java
##########
@@ -824,6 +831,92 @@ public void testPutRetainsIsDeletedInParentListing()
throws Exception {
}
}
+ @Test
+ public void testPruneExpiredTombstones() throws Exception {
+ List<String> keepFilenames = new ArrayList<>(
+ Arrays.asList("/dir1/fileK1", "/dir1/fileK2", "/dir1/fileK3"));
+ List<String> removeFilenames = new ArrayList<>(
+ Arrays.asList("/dir1/fileR1", "/dir1/fileR2", "/dir1/fileR3"));
+
+ long cutoff = 9001;
+
+ for(String fN : keepFilenames) {
+ final PathMetadata pathMetadata = new PathMetadata(makeFileStatus(fN,
1));
+ pathMetadata.setLastUpdated(9002L);
+ ms.put(pathMetadata);
+ }
+
+ for(String fN : removeFilenames) {
+ final PathMetadata pathMetadata = new PathMetadata(makeFileStatus(fN,
1));
+ pathMetadata.setLastUpdated(9000L);
+ // tombstones are the deleted files!
+ pathMetadata.setIsDeleted(true);
+ ms.put(pathMetadata);
+ }
+
+ ms.prune(MetadataStore.PruneMode.TOMBSTONES_BY_LASTUPDATED, cutoff);
+
+ if(!allowMissing()) {
+ for (String fN : keepFilenames) {
+ final PathMetadata pathMetadata = ms.get(strToPath(fN));
+ assertNotNull(pathMetadata);
+ }
+ }
+
+ for(String fN : removeFilenames) {
+ final PathMetadata pathMetadata = ms.get(strToPath(fN));
+ assertNull(pathMetadata);
+ }
+ }
+
+ @Test
+ public void testPruneExpiredTombstonesSpecifiedPath() throws Exception {
+ List<String> keepFilenames = new ArrayList<>(
+ Arrays.asList("/dir1/fileK1", "/dir1/fileK2", "/dir1/fileK3"));
+ List<String> removeFilenames = new ArrayList<>(
+ Arrays.asList("/dir2/fileR1", "/dir2/fileR2", "/dir2/fileR3"));
+
+ long cutoff = 9001;
+
+ // Both are expired. Difference is it will only delete the specified one.
+ for(String fN : keepFilenames) {
+ final PathMetadata pathMetadata = new PathMetadata(makeFileStatus(fN,
1));
+ pathMetadata.setLastUpdated(9002L);
+ ms.put(pathMetadata);
+ }
+
+ for(String fN : removeFilenames) {
+ final PathMetadata pathMetadata = new PathMetadata(makeFileStatus(fN,
1));
+ pathMetadata.setLastUpdated(9000L);
+ // tombstones are the deleted files!
+ pathMetadata.setIsDeleted(true);
+ ms.put(pathMetadata);
+ }
+
+ final Map<String, String> diagnostics = ms.getDiagnostics();
+ if (ms instanceof LocalMetadataStore){
Review comment:
the red flag is that the **abstract class** is doing this. I have to correct
this indeed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]