-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-3286. BasicOzoneFileSystem support batchDelete. #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -382,6 +382,21 @@ public void deleteKey(String key) throws IOException { | |
| proxy.deleteKey(volumeName, name, key); | ||
| } | ||
|
|
||
| /** | ||
| * Deletes the given list of keys from the bucket. | ||
| * @param keyList List of the key name to be deleted. | ||
| * @throws IOException | ||
| */ | ||
| public void deleteKeys(List<String> keyList) throws IOException { | ||
|
||
| proxy.deleteKeys(volumeName, name, keyList); | ||
| } | ||
|
|
||
| /** | ||
| * Rename the keyname from fromKeyName to toKeyName. | ||
| * @param fromKeyName The original key name. | ||
| * @param toKeyName New key name. | ||
| * @throws IOException | ||
| */ | ||
| public void renameKey(String fromKeyName, String toKeyName) | ||
captainzmc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| throws IOException { | ||
| proxy.renameKey(volumeName, name, fromKeyName, toKeyName); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ | |
|
|
||
| import org.apache.commons.io.IOUtils; | ||
|
|
||
| import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNotEquals; | ||
|
|
@@ -171,6 +172,7 @@ public void testFileSystem() throws Exception { | |
|
|
||
|
||
| testCreateDoesNotAddParentDirKeys(); | ||
| testDeleteCreatesFakeParentDir(); | ||
| testFileDelete(); | ||
| testNonExplicitlyCreatedPathExistsAfterItsLeafsWereRemoved(); | ||
|
|
||
| testRenameDir(); | ||
|
|
@@ -204,6 +206,8 @@ private void setupOzoneFileSystem() | |
|
|
||
| // Set the fs.defaultFS and start the filesystem | ||
| conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, rootPath); | ||
| // Set the number of keys to be processed during batch operate. | ||
| conf.setInt(OZONE_FS_ITERATE_BATCH_SIZE, 5); | ||
| fs = FileSystem.get(conf); | ||
| } | ||
|
|
||
|
|
@@ -262,6 +266,44 @@ private void testDeleteCreatesFakeParentDir() throws Exception { | |
| assertEquals(parentKey, parentKeyInfo.getName()); | ||
| } | ||
|
|
||
|
||
| private void testFileDelete() throws Exception { | ||
| Path grandparent = new Path("/testBatchDelete"); | ||
| Path parent = new Path(grandparent, "parent"); | ||
| Path childFolder = new Path(parent, "childFolder"); | ||
| // BatchSize is 5, so we're going to set a number that's not a | ||
| // multiple of 5. In order to test the final number of keys less than | ||
| // batchSize can also be deleted. | ||
| for (int i = 0; i < 8; i++) { | ||
| Path childFile = new Path(parent, "child" + i); | ||
| Path childFolderFile = new Path(childFolder, "child" + i); | ||
| ContractTestUtils.touch(fs, childFile); | ||
| ContractTestUtils.touch(fs, childFolderFile); | ||
| } | ||
|
|
||
| assertTrue(fs.listStatus(grandparent).length == 1); | ||
| assertTrue(fs.listStatus(parent).length == 9); | ||
| assertTrue(fs.listStatus(childFolder).length == 8); | ||
|
|
||
| Boolean successResult = fs.delete(grandparent, true); | ||
| assertTrue(successResult); | ||
| assertTrue(!o3fs.exists(grandparent)); | ||
| for (int i = 0; i < 8; i++) { | ||
| Path childFile = new Path(parent, "child" + i); | ||
| // Make sure all keys under testBatchDelete/parent should be deleted | ||
| assertTrue(!o3fs.exists(childFile)); | ||
|
|
||
| // Test to recursively delete child folder, make sure all keys under | ||
| // testBatchDelete/parent/childFolder should be deleted. | ||
| Path childFolderFile = new Path(childFolder, "child" + i); | ||
| assertTrue(!o3fs.exists(childFolderFile)); | ||
| } | ||
| // Will get: WARN ozone.BasicOzoneFileSystem delete: Path does not exist. | ||
| // This will return false. | ||
| Boolean falseResult = fs.delete(parent, true); | ||
| assertFalse(falseResult); | ||
|
|
||
| } | ||
|
|
||
| private void testListStatus() throws Exception { | ||
| Path parent = new Path("/testListStatus"); | ||
| Path file1 = new Path(parent, "key1"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this property be used for batch rename too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, batch Rename will also use this property.