Skip to content

Commit df4e3f6

Browse files
committed
Add comments whereever needed
1 parent 0c9cca7 commit df4e3f6

File tree

1 file changed

+28
-19
lines changed
  • hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services

1 file changed

+28
-19
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,12 +1560,17 @@ private AbfsClientRenameResult renameWithCTIdRecovery(String source,
15601560
try {
15611561
incrementAbfsRenamePath();
15621562
op.execute(tracingContext);
1563+
// AbfsClientResult contains the AbfsOperation, If recovery happened or
1564+
// not, and the incompleteMetaDataState is true or false.
1565+
// If we successfully rename a path and isMetadataIncompleteState was
1566+
// true, then rename was recovered, else it didn't, this is why
1567+
// isMetadataIncompleteState is used for renameRecovery(as the 2nd param).
15631568
return new AbfsClientRenameResult(op, isMetadataIncompleteState,
15641569
isMetadataIncompleteState);
15651570
} catch (AzureBlobFileSystemException e) {
1566-
if (!op.hasResult()) {
1567-
throw e;
1568-
}
1571+
// Handle rename exceptions and retry if applicable
1572+
handleRenameException(source, destination, continuation,
1573+
tracingContext, sourceEtag, op, isMetadataIncompleteState, e);
15691574

15701575
// Check if the operation is a retried request and if the error code indicates
15711576
// that the source path was not found. If so, attempt recovery using CTId.
@@ -1580,10 +1585,6 @@ private AbfsClientRenameResult renameWithCTIdRecovery(String source,
15801585
}
15811586
}
15821587

1583-
// Handle rename exceptions and retry if applicable
1584-
handleRenameException(source, destination, continuation,
1585-
tracingContext, sourceEtag, op, isMetadataIncompleteState);
1586-
15871588
// Attempt recovery using ETag if applicable
15881589
if (recoveryUsingEtag(source, destination, sourceEtag,
15891590
op, tracingContext, true)) {
@@ -1617,6 +1618,9 @@ private AbfsClientRenameResult renameWithETagRecovery(String source,
16171618
boolean hasEtag = !isEmpty(sourceEtag);
16181619
boolean shouldAttemptRecovery = isRenameResilience() && getIsNamespaceEnabled();
16191620
if (!hasEtag && shouldAttemptRecovery) {
1621+
// in case eTag is already not supplied to the API
1622+
// and rename resilience is expected and it is an HNS enabled account
1623+
// fetch the source etag to be used later in recovery
16201624
try {
16211625
final AbfsRestOperation srcStatusOp = getPathStatus(source,
16221626
false, tracingContext, null);
@@ -1648,16 +1652,17 @@ private AbfsClientRenameResult renameWithETagRecovery(String source,
16481652
try {
16491653
incrementAbfsRenamePath();
16501654
op.execute(tracingContext);
1655+
// AbfsClientResult contains the AbfsOperation, If recovery happened or
1656+
// not, and the incompleteMetaDataState is true or false.
1657+
// If we successfully rename a path and isMetadataIncompleteState was
1658+
// true, then rename was recovered, else it didn't, this is why
1659+
// isMetadataIncompleteState is used for renameRecovery(as the 2nd param).
16511660
return new AbfsClientRenameResult(op, isMetadataIncompleteState,
16521661
isMetadataIncompleteState);
16531662
} catch (AzureBlobFileSystemException e) {
1654-
if (!op.hasResult()) {
1655-
throw e;
1656-
}
1657-
16581663
// Handle rename exceptions and retry if applicable
16591664
handleRenameException(source, destination, continuation,
1660-
tracingContext, sourceEtag, op, isMetadataIncompleteState);
1665+
tracingContext, sourceEtag, op, isMetadataIncompleteState, e);
16611666

16621667
// Attempt recovery using ETag if applicable
16631668
if (recoveryUsingEtag(source, destination, sourceEtag,
@@ -1781,18 +1786,22 @@ private boolean recoveryUsingEtag(String source, String destination,
17811786
private void handleRenameException(final String source,
17821787
final String destination, final String continuation,
17831788
final TracingContext tracingContext, final String sourceEtag,
1784-
final AbfsRestOperation op, boolean isMetadataIncompleteState)
1785-
throws IOException {
1786-
// Check if the rename operation failed due to unauthorized overwrite
1787-
// and if so, throw a FileAlreadyExistsException.
1789+
final AbfsRestOperation op, boolean isMetadataIncompleteState,
1790+
AzureBlobFileSystemException e) throws IOException {
1791+
if (!op.hasResult()) {
1792+
throw e;
1793+
}
1794+
1795+
// ref: HADOOP-19393. Write permission checks can occur before validating
1796+
// rename operation's validity. If there is an existing destination path, it may be rejected
1797+
// with an authorization error. Catching and throwing FileAlreadyExistsException instead.
17881798
if (UNAUTHORIZED_BLOB_OVERWRITE.getErrorCode()
17891799
.equals(op.getResult().getStorageErrorCode())) {
17901800
throw new FileAlreadyExistsException(ERR_FILE_ALREADY_EXISTS);
17911801
}
17921802

1793-
// Check if the destination parent path is not found
1794-
// and if the metadata state is incomplete.
1795-
// If so, retry the rename operation.
1803+
// ref: HADOOP-18242. Rename failure occurring due to a rare case of
1804+
// tracking metadata being in incomplete state.
17961805
if (RENAME_DESTINATION_PARENT_PATH_NOT_FOUND.getErrorCode()
17971806
.equals(op.getResult().getStorageErrorCode())
17981807
&& !isMetadataIncompleteState) {

0 commit comments

Comments
 (0)