-
Notifications
You must be signed in to change notification settings - Fork 0
RenameDir and DeleteDir on blob to push number of blobs operated on last API call. #76
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
221b21f
1ce1479
f581bec
e16000f
816c34b
c4533fe
742e357
997127c
740e312
7df7df9
673b0f9
a8783f2
70be95e
641a84b
3439b1b
609d65d
4f3e47c
643c10f
2e9f1ab
1607a11
1d4b6ba
460fd86
c35c714
8bde5da
024b451
a943c31
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 |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ | |
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.Future; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| import org.apache.hadoop.classification.VisibleForTesting; | ||
|
|
||
|
|
@@ -1580,6 +1581,7 @@ private void renameBlobDir(final Path source, | |
| final ExecutorService renameBlobExecutorService | ||
| = Executors.newFixedThreadPool( | ||
| getAbfsConfiguration().getBlobDirRenameMaxThread()); | ||
| AtomicInteger renamedBlob = new AtomicInteger(0); | ||
| while(!listBlobConsumer.isCompleted()) { | ||
| blobList = listBlobConsumer.consume(); | ||
| if(blobList == null) { | ||
|
|
@@ -1611,6 +1613,7 @@ private void renameBlobDir(final Path source, | |
| blobProperty.getPath(), source), | ||
| blobLease, | ||
| tracingContext); | ||
| renamedBlob.incrementAndGet(); | ||
| } catch (AzureBlobFileSystemException e) { | ||
| LOG.error(String.format("rename from %s to %s for blob %s failed", | ||
| source, destination, blobProperty.getPath()), e); | ||
|
|
@@ -1634,11 +1637,13 @@ private void renameBlobDir(final Path source, | |
| } | ||
| renameBlobExecutorService.shutdown(); | ||
|
|
||
| tracingContext.setOperatedBlobCount(renamedBlob.get() + 1); | ||
| renameBlob( | ||
| source, createDestinationPathForBlobPartOfRenameSrcDir(destination, | ||
| source, source), | ||
| srcDirBlobLease, | ||
| tracingContext); | ||
| tracingContext.setOperatedBlobCount(null); | ||
| } | ||
|
|
||
| private Boolean isCreateOperationOnBlobEndpoint() { | ||
|
|
@@ -1757,7 +1762,6 @@ private void deleteBlobPath(final Path path, | |
| if (!path.isRoot()) { | ||
| listSrcBuilder.append(FORWARD_SLASH); | ||
| } | ||
|
|
||
| String listSrc = listSrcBuilder.toString(); | ||
| BlobList blobList = client.getListBlobs(null, listSrc, null, null, | ||
| tracingContext).getResult().getBlobList(); | ||
|
|
@@ -1868,6 +1872,7 @@ private void createParentDirectory(final Path path, | |
| private void deleteOnConsumedBlobs(final Path srcPath, | ||
| final ListBlobConsumer consumer, | ||
| final TracingContext tracingContext) throws AzureBlobFileSystemException { | ||
| AtomicInteger deletedBlobCount = new AtomicInteger(0); | ||
| String srcPathStr = srcPath.toUri().getPath(); | ||
| ExecutorService deleteBlobExecutorService = Executors.newFixedThreadPool( | ||
| getAbfsConfiguration().getBlobDirDeleteMaxThread()); | ||
|
|
@@ -1885,6 +1890,7 @@ private void deleteOnConsumedBlobs(final Path srcPath, | |
| try { | ||
| client.deleteBlobPath(blobProperty.getPath(), null, | ||
| tracingContext); | ||
| deletedBlobCount.incrementAndGet(); | ||
| } catch (AzureBlobFileSystemException ex) { | ||
| if (ex instanceof AbfsRestOperationException | ||
| && ((AbfsRestOperationException) ex).getStatusCode() | ||
|
|
@@ -1912,6 +1918,8 @@ private void deleteOnConsumedBlobs(final Path srcPath, | |
| } finally { | ||
| deleteBlobExecutorService.shutdown(); | ||
| } | ||
|
|
||
| tracingContext.setOperatedBlobCount(deletedBlobCount.get() + 1); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Increment is being done only for blobs in renamed in parallel This +1 is for blob which would contain the count value in CID. |
||
| if (!srcPath.isRoot()) { | ||
| try { | ||
| LOG.debug(String.format("Deleting Path %s", srcPathStr)); | ||
|
|
@@ -1926,6 +1934,7 @@ private void deleteOnConsumedBlobs(final Path srcPath, | |
| String.format("Path %s is an implicit directory", srcPathStr)); | ||
| } | ||
| } | ||
| tracingContext.setOperatedBlobCount(null); | ||
| } | ||
|
|
||
| public FileStatus getFileStatus(Path path, TracingContext tracingContext, boolean useBlobEndpoint) throws IOException { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.concurrent.Callable; | ||
| import java.util.concurrent.ExecutorService; | ||
|
|
@@ -414,4 +415,68 @@ public void testDeleteCheckIfParentLMTChange() throws Exception { | |
| Long newLmt = fs.getFileStatus(new Path("/dir1")).getModificationTime(); | ||
| Assertions.assertThat(lmt).isEqualTo(newLmt); | ||
| } | ||
|
|
||
| /** | ||
| * Test to assert that the CID in src marker delete contains the | ||
| * total number of blobs operated in the delete directory. | ||
| * Also, to assert that all operations in the delete-directory flow have same | ||
| * primaryId and opType. | ||
| */ | ||
| @Test | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add a small description for each test as in what the test is trying to achieve ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added as javadoc in all new tests. |
||
| public void testDeleteEmitDeletionCountInClientRequestId() throws Exception { | ||
| AzureBlobFileSystem fs = Mockito.spy(getFileSystem()); | ||
| Assume.assumeTrue(getPrefixMode(fs) == PrefixMode.BLOB); | ||
| String dirPathStr = "/testDir/dir1"; | ||
| fs.mkdirs(new Path(dirPathStr)); | ||
| ExecutorService executorService = Executors.newFixedThreadPool(5); | ||
| List<Future> futures = new ArrayList<>(); | ||
| for (int i = 0; i < 10; i++) { | ||
| final int iter = i; | ||
| Future future = executorService.submit(() -> { | ||
| return fs.create(new Path("/testDir/dir1/file" + iter)); | ||
| }); | ||
| futures.add(future); | ||
| } | ||
|
|
||
| for (Future future : futures) { | ||
| future.get(); | ||
| } | ||
| executorService.shutdown(); | ||
|
|
||
|
|
||
| AzureBlobFileSystemStore store = Mockito.spy(fs.getAbfsStore()); | ||
| Mockito.doReturn(store).when(fs).getAbfsStore(); | ||
| AbfsClient client = Mockito.spy(store.getClient()); | ||
| store.setClient(client); | ||
|
|
||
| final TracingHeaderValidator tracingHeaderValidator | ||
| = new TracingHeaderValidator( | ||
| fs.getAbfsStore().getAbfsConfiguration().getClientCorrelationId(), | ||
| fs.getFileSystemId(), FSOperationType.DELETE, true, 0); | ||
| fs.registerListener(tracingHeaderValidator); | ||
|
|
||
| Mockito.doAnswer(answer -> { | ||
| Mockito.doAnswer(deleteAnswer -> { | ||
| if (dirPathStr.equalsIgnoreCase( | ||
| ((Path) deleteAnswer.getArgument(0)).toUri().getPath())) { | ||
| tracingHeaderValidator.setOperatedBlobCount(11); | ||
| Object result = deleteAnswer.callRealMethod(); | ||
| tracingHeaderValidator.setOperatedBlobCount(null); | ||
| return result; | ||
| } | ||
| return deleteAnswer.callRealMethod(); | ||
| }) | ||
| .when(client) | ||
| .deleteBlobPath(Mockito.any(Path.class), | ||
| Mockito.nullable(String.class), | ||
| Mockito.any(TracingContext.class)); | ||
|
|
||
| return answer.callRealMethod(); | ||
| }) | ||
| .when(store) | ||
| .delete(Mockito.any(Path.class), Mockito.anyBoolean(), | ||
| Mockito.any(TracingContext.class)); | ||
|
|
||
| fs.delete(new Path(dirPathStr), true); | ||
| } | ||
| } | ||
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.
Since we are already doing an increment and get, why +1 here ?
Uh oh!
There was an error while loading. Please reload this page.
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.
Increment is being done only for blobs in renamed in parallel
This +1 is for blob which would contain the count value in CID.