-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19445: ABFS: [FnsOverBlob][Tests] Add Tests For Negative Scenarios Identified for Rename Operation #7386
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 4 commits
0bfe007
35b31f9
6f5a3a3
47eccd5
152f9c2
7c71345
da81cc8
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 |
|---|---|---|
|
|
@@ -84,7 +84,6 @@ | |
| import static java.net.HttpURLConnection.HTTP_OK; | ||
| import static java.net.HttpURLConnection.HTTP_PRECON_FAILED; | ||
| import static org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.extractEtagHeader; | ||
| import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.CALL_GET_FILE_STATUS; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.ACQUIRE_LEASE_ACTION; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.AND_MARK; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.APPEND_BLOB_TYPE; | ||
|
|
@@ -424,7 +423,7 @@ private void fixAtomicEntriesInListResults(final AbfsRestOperation op, | |
| } | ||
| List<BlobListResultEntrySchema> filteredEntries = new ArrayList<>(); | ||
| for (BlobListResultEntrySchema entry : listResultSchema.paths()) { | ||
| if (!takeListPathAtomicRenameKeyAction(entry.path(), | ||
| if (!takeListPathAtomicRenameKeyAction(entry.path(), entry.isDirectory(), | ||
| entry.contentLength().intValue(), tracingContext)) { | ||
| filteredEntries.add(entry); | ||
| } | ||
|
|
@@ -444,15 +443,14 @@ public void createNonRecursivePreCheck(Path parentPath, | |
| } | ||
| getPathStatus(parentPath.toUri().getPath(), false, | ||
| tracingContext, null); | ||
| incrementAbfsGetPathStatus(); | ||
| } catch (AbfsRestOperationException ex) { | ||
| if (ex.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { | ||
| throw new FileNotFoundException("Cannot create file " | ||
| + parentPath.toUri().getPath() | ||
| + " because parent folder does not exist."); | ||
| } | ||
| throw ex; | ||
|
Contributor
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. The increase will not get implemented if getPathStatus call fails
Contributor
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. Moved it to finally block |
||
| } finally { | ||
| getAbfsCounters().incrementCounter(CALL_GET_FILE_STATUS, 1); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -510,6 +508,7 @@ protected AbfsRestOperation createMarkerAtPath(final String path, | |
| final String eTag, | ||
| final ContextEncryptionAdapter contextEncryptionAdapter, | ||
| final TracingContext tracingContext) throws AzureBlobFileSystemException { | ||
| incrementAbfsCreateFile(); | ||
| return createPathRestOp(path, false, false, false, eTag, | ||
| contextEncryptionAdapter, tracingContext); | ||
| } | ||
|
|
@@ -807,7 +806,6 @@ public AbfsClientRenameResult renamePath(final String source, | |
| BlobRenameHandler blobRenameHandler = getBlobRenameHandler(source, | ||
| destination, sourceEtag, isAtomicRenameKey(source), tracingContext | ||
| ); | ||
| incrementAbfsRenamePath(); | ||
| if (blobRenameHandler.execute()) { | ||
| final AbfsUriQueryBuilder abfsUriQueryBuilder | ||
| = createDefaultUriQueryBuilder(); | ||
|
|
@@ -1751,6 +1749,7 @@ public void takeGetPathStatusAtomicRenameKeyAction(final Path path, | |
| pendingJsonFileStatus = getPathStatus( | ||
| pendingJsonPath.toUri().getPath(), tracingContext, | ||
| null, false); | ||
| incrementAbfsGetPathStatus(); | ||
|
||
| if (checkIsDir(pendingJsonFileStatus.getResult())) { | ||
| return; | ||
| } | ||
|
|
@@ -1805,11 +1804,11 @@ public void takeGetPathStatusAtomicRenameKeyAction(final Path path, | |
| * @throws AzureBlobFileSystemException server error | ||
| */ | ||
| private boolean takeListPathAtomicRenameKeyAction(final Path path, | ||
| final int renamePendingJsonLen, | ||
| final boolean isDirectory, final int renamePendingJsonLen, | ||
| final TracingContext tracingContext) | ||
| throws AzureBlobFileSystemException { | ||
| if (path == null || path.isRoot() || !isAtomicRenameKey( | ||
| path.toUri().getPath()) || !path.toUri() | ||
| path.toUri().getPath()) || isDirectory || !path.toUri() | ||
| .getPath() | ||
| .endsWith(RenameAtomicity.SUFFIX)) { | ||
| return false; | ||
|
|
@@ -1837,7 +1836,7 @@ private boolean takeListPathAtomicRenameKeyAction(final Path path, | |
| } | ||
|
|
||
| @VisibleForTesting | ||
| RenameAtomicity getRedoRenameAtomicity(final Path renamePendingJsonPath, | ||
| public RenameAtomicity getRedoRenameAtomicity(final Path renamePendingJsonPath, | ||
| int fileLen, | ||
| final TracingContext tracingContext) { | ||
| return new RenameAtomicity(renamePendingJsonPath, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,10 @@ | |
| import org.apache.hadoop.util.concurrent.HadoopExecutors; | ||
|
|
||
| import static org.apache.commons.lang3.StringUtils.isNotEmpty; | ||
| import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.CALL_GET_FILE_STATUS; | ||
| import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_COPIED; | ||
| import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_CREATED; | ||
| import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.FILES_DELETED; | ||
| import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.RENAME_PATH_ATTEMPTS; | ||
| import static org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.extractEtagHeader; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.APN_VERSION; | ||
|
|
@@ -693,6 +697,34 @@ protected void incrementAbfsRenamePath() { | |
| abfsCounters.incrementCounter(RENAME_PATH_ATTEMPTS, 1); | ||
| } | ||
|
|
||
| /** | ||
| * Increments AbfsCounters for get path status by 1. | ||
| */ | ||
| protected void incrementAbfsGetPathStatus() { | ||
|
||
| abfsCounters.incrementCounter(CALL_GET_FILE_STATUS, 1); | ||
| } | ||
|
|
||
| /** | ||
| * Increments AbfsCounters for Delete File by 1. | ||
| */ | ||
| protected void incrementAbfsDeleteFile() { | ||
| abfsCounters.incrementCounter(FILES_DELETED, 1); | ||
| } | ||
|
|
||
| /** | ||
| * Increments AbfsCounters for Create File by 1. | ||
| */ | ||
| protected void incrementAbfsCreateFile() { | ||
| abfsCounters.incrementCounter(FILES_CREATED, 1); | ||
| } | ||
|
|
||
| /** | ||
| * Increments AbfsCounters for Copy Files by 1. | ||
| */ | ||
| protected void incrementAbfsCopyFile() { | ||
| abfsCounters.incrementCounter(FILES_COPIED, 1); | ||
| } | ||
|
|
||
| /** | ||
| * Check if the rename request failure is post a retry and if earlier rename | ||
| * request might have succeeded at back-end. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ int getMaxConsumptionParallelism() { | |
| private boolean deleteInternal(final Path path) | ||
| throws AzureBlobFileSystemException { | ||
| getAbfsClient().deleteBlobPath(path, null, tracingContext); | ||
| getAbfsClient().incrementAbfsDeleteFile(); | ||
|
||
| deleteCount.incrementAndGet(); | ||
| return true; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import org.apache.hadoop.fs.azurebfs.AbfsConfiguration; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.FileSystemOperationUnhandledException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidConfigurationValueException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.services.BlobListResultSchema; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.services.ListResultEntrySchema; | ||
|
|
@@ -119,7 +120,14 @@ private boolean takeAction(List<Path> paths) | |
| LOG.debug("Thread interrupted while taking action on path: {}", | ||
| path.toUri().getPath()); | ||
| } catch (ExecutionException e) { | ||
| executionException = (AzureBlobFileSystemException) e.getCause(); | ||
| LOG.debug("Execution exception while taking action on path: {}", | ||
| path.toUri().getPath()); | ||
| if (e.getCause() instanceof AzureBlobFileSystemException) { | ||
| executionException = (AzureBlobFileSystemException) e.getCause(); | ||
| } else { | ||
| executionException = | ||
| new FileSystemOperationUnhandledException(executionException); | ||
| } | ||
| } | ||
| } | ||
| if (executionException != null) { | ||
|
|
@@ -261,7 +269,7 @@ protected String listAndEnqueue(final ListBlobQueue listBlobQueue, | |
| protected void addPaths(final List<Path> paths, | ||
| final ListResultSchema retrievedSchema) { | ||
| for (ListResultEntrySchema entry : retrievedSchema.paths()) { | ||
| Path entryPath = new Path(ROOT_PATH, entry.name()); | ||
| Path entryPath = new Path(ROOT_PATH + entry.name()); | ||
|
Contributor
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. Why this change?
Contributor
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. As discussed offline, this change is needed because of new Path() behavior in hadoop common. |
||
| if (!entryPath.equals(this.path)) { | ||
| paths.add(entryPath); | ||
| } | ||
|
|
||
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.
should call incrementAbfsDeleteFile ?
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.
We are incrementing Delete Files in Client.