anujmodi2021 commented on code in PR #7509: URL: https://github.com/apache/hadoop/pull/7509#discussion_r2026158411
########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java: ########## @@ -1691,4 +1555,297 @@ public String addClientTransactionIdToHeader(List<AbfsHttpHeader> requestHeaders } return clientTransactionId; } + + /** + * Attempts to rename a path with client transaction ID (CTId) recovery mechanism. + * If the initial rename attempt fails, it tries to recover using CTId or ETag + * and retries the operation. + * + * @param source the source path to be renamed + * @param destination the destination path for the rename + * @param continuation the continuation token for the operation + * @param tracingContext the context for tracing the operation + * @param sourceEtag the ETag of the source path for conditional requests + * @param isMetadataIncompleteState flag indicating if the metadata state is incomplete + * @return an {@link AbfsClientRenameResult} containing the result of the rename operation + * @throws IOException if an error occurs during the rename operation + */ + private AbfsClientRenameResult renameWithCTIdRecovery(String source, + String destination, String continuation, TracingContext tracingContext, + String sourceEtag, boolean isMetadataIncompleteState) throws IOException { + // Get request headers for rename operation + List<AbfsHttpHeader> requestHeaders = getHeadersForRename(source); + // Add client transaction ID to the request headers + String clientTransactionId = addClientTransactionIdToHeader(requestHeaders); + + // Create the URL for the rename operation + final URL url = createRequestUrl(destination, + getRenameQueryBuilder(destination, continuation).toString()); + + // Create the rename operation + AbfsRestOperation op = createRenameRestOperation(url, requestHeaders); + try { + incrementAbfsRenamePath(); + op.execute(tracingContext); + // If we successfully rename a path and isMetadataIncompleteState is true, + // then the rename was recovered; otherwise, it wasn’t. + // This is why isMetadataIncompleteState is used for renameRecovery (as the second parameter). + return new AbfsClientRenameResult(op, isMetadataIncompleteState, + isMetadataIncompleteState); + } catch (AzureBlobFileSystemException e) { + // Handle rename exceptions and retry if applicable + handleRenameException(source, destination, continuation, Review Comment: Makes sense. Please add some code comments to make all this more readable and easily understandable. In the main Javadoc for both types(Etag and CT) of rename it would be godd to explain the whole flow of recovery -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org