aswinshakil commented on code in PR #4543:
URL: https://github.com/apache/ozone/pull/4543#discussion_r1164448853
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestDirectoryDeletingServiceWithFSO.java:
##########
@@ -374,6 +376,128 @@ public void testDeleteFilesAndSubFiles() throws Exception
{
assertEquals(prevDeletedKeyCount + 5, currentDeletedKeyCount);
}
+ @Test
+ public void testDirDeletedTableCleanUpForSnapshot() throws Exception {
+ Table<String, OmKeyInfo> deletedDirTable =
+ cluster.getOzoneManager().getMetadataManager().getDeletedDirTable();
+ Table<String, OmKeyInfo> keyTable =
+ cluster.getOzoneManager().getMetadataManager()
+ .getKeyTable(getFSOBucketLayout());
+ Table<String, OmDirectoryInfo> dirTable =
+ cluster.getOzoneManager().getMetadataManager().getDirectoryTable();
+ Table<String, RepeatedOmKeyInfo> deletedKeyTable =
+ cluster.getOzoneManager().getMetadataManager().getDeletedTable();
+ Table<String, SnapshotInfo> snapshotInfoTable =
+ cluster.getOzoneManager().getMetadataManager().getSnapshotInfoTable();
+
+ /* DirTable KeyTable
+ /v/b/snapDir /v/b/snapDir/testKey0 - testKey5
+ /v/b/snapDir/appRoot/
/v/b/snapDir/appRoot/parentDir0/childFile
+ /v/b/snapDir/appRoot/parentDir0/
/v/b/snapDir/appRoot/parentDir1/childFile
+ /v/b/snapDir/appRoot/parentDir1/
/v/b/snapDir/appRoot/parentDir2/childFile
+ /v/b/snapDir/appRoot/parentDir2/
+ */
+
+ Path root = new Path("/snapDir");
+ Path appRoot = new Path(root, "appRoot");
+ // Create parent dir from root.
+ fs.mkdirs(root);
+
+ // Added 5 sub files inside root dir
+ for (int i = 0; i < 5; i++) {
+ Path path = new Path(root, "testKey" + i);
+ try (FSDataOutputStream stream = fs.create(path)) {
+ stream.write(1);
+ }
+ }
+
+ // Add 3 more sub files in different level
+ for (int i = 0; i < 3; i++) {
+ Path parent = new Path(appRoot, "parentDir" + i);
+ Path child = new Path(parent, "childFile");
+ ContractTestUtils.touch(fs, child);
+ }
+
+ KeyDeletingService keyDeletingService =
+ (KeyDeletingService) cluster.getOzoneManager().getKeyManager()
+ .getDeletingService();
+
+ // Before delete
+ assertTableRowCount(deletedDirTable, 0);
+ assertTableRowCount(keyTable, 8);
+ assertTableRowCount(dirTable, 5);
+
+ // Create snapshot
+ client.getObjectStore().createSnapshot(volumeName, bucketName, "snap1");
+ assertTableRowCount(snapshotInfoTable, 1);
+
+ // Case-1) Delete 3 Files directly.
+ for (int i = 0; i < 3; i++) {
+ Path path = new Path(root, "testKey" + i);
+ fs.delete(path, true);
+ }
+
+ DirectoryDeletingService dirDeletingService =
+ (DirectoryDeletingService) cluster.getOzoneManager().getKeyManager()
+ .getDirDeletingService();
+
+ // After delete. 5 more files left out under the root dir
+ assertTableRowCount(keyTable, 5);
+ assertTableRowCount(dirTable, 5);
+
+ // KeyDeletingService and DirectoryDeletingService will not
+ // clean up because the paths are part of a snapshot.
+ assertTableRowCount(deletedDirTable, 0);
+ assertTableRowCount(deletedKeyTable, 3);
+
+ assertSubPathsCount(dirDeletingService::getMovedFilesCount, 0);
+ assertSubPathsCount(dirDeletingService::getMovedDirsCount, 0);
+ assertSubPathsCount(dirDeletingService::getDeletedDirsCount, 0);
+
+ // Case-2) Delete dir
+ fs.delete(root, true);
Review Comment:
I don't think we can pause at that time.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]