[
https://issues.apache.org/jira/browse/HADOOP-19233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17912366#comment-17912366
]
ASF GitHub Bot commented on HADOOP-19233:
-----------------------------------------
anmolanmol1234 commented on code in PR #7265:
URL: https://github.com/apache/hadoop/pull/7265#discussion_r1912744844
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java:
##########
@@ -1318,6 +1421,128 @@ public static String getDirectoryQueryParameter(final
String path) {
return directory;
}
+ public boolean isAtomicRenameKey(String key) {
+ return isKeyForDirectorySet(key, azureAtomicRenameDirSet);
+ }
+
+ /**
+ * Action to be taken when atomic-key is present on a getPathStatus path.
+ *
+ * @param path path of the pendingJson for the atomic path.
+ * @param pathLease lease on the path.
+ * @param tracingContext tracing context.
+ *
+ * @throws AzureBlobFileSystemException server error or the path is
renamePending json file and action is taken.
+ */
+ public void takeGetPathStatusAtomicRenameKeyAction(final Path path,
+ final AbfsLease pathLease,
+ final TracingContext
tracingContext)
+ throws AzureBlobFileSystemException {
+ if (path == null || path.isRoot() ||
!isAtomicRenameKey(path.toUri().getPath())) {
+ return;
+ }
+ AbfsRestOperation pendingJsonFileStatus;
+ Path pendingJsonPath = new Path(path.getParent(),
+ path.toUri().getPath() + RenameAtomicity.SUFFIX);
+ try {
+ pendingJsonFileStatus = getPathStatus(
+ pendingJsonPath.toUri().getPath(), tracingContext, null, false);
+ if (checkIsDir(pendingJsonFileStatus.getResult())) {
+ return;
+ }
+ } catch (AbfsRestOperationException ex) {
+ if (ex.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ return;
+ }
+ throw ex;
+ }
+
+ boolean renameSrcHasChanged;
+ try {
+ RenameAtomicity renameAtomicity = getRedoRenameAtomicity(
+ pendingJsonPath,
Integer.parseInt(pendingJsonFileStatus.getResult()
+
.getResponseHeader(HttpHeaderConfigurations.CONTENT_LENGTH)),
+ tracingContext, pathLease);
+ renameAtomicity.redo();
+ renameSrcHasChanged = false;
+ } catch (AbfsRestOperationException ex) {
+ /*
+ * At this point, the source marked by the renamePending json file,
might have
+ * already got renamed by some parallel thread, or at this point, the
path
+ * would have got modified which would result in eTag change, which
would lead
+ * to a HTTP_CONFLICT. In this case, no more operation needs to be
taken, and
+ * the calling getPathStatus can return this source path as result.
+ */
+ if (ex.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND
+ || ex.getStatusCode() == HttpURLConnection.HTTP_CONFLICT) {
+ renameSrcHasChanged = true;
+ } else {
+ throw ex;
+ }
+ }
+ if (!renameSrcHasChanged) {
+ throw new AbfsRestOperationException(
+ AzureServiceErrorCode.PATH_NOT_FOUND.getStatusCode(),
+ AzureServiceErrorCode.PATH_NOT_FOUND.getErrorCode(),
+ ATOMIC_DIR_RENAME_RECOVERY_ON_GET_PATH_EXCEPTION,
+ null);
+ }
+ }
+
+ /**
+ * Action to be taken when atomic-key is present on a listPath path.
+ *
+ * @param path path of the pendingJson for the atomic path.
+ * @param renamePendingJsonLen length of the pendingJson file.
+ * @param tracingContext tracing context.
+ *
+ * @return true if action is taken.
+ * @throws AzureBlobFileSystemException server error
+ */
+ private boolean takeListPathAtomicRenameKeyAction(final Path path,
+ final int
renamePendingJsonLen,
+ final TracingContext
tracingContext)
+ throws AzureBlobFileSystemException {
+ if (path == null || path.isRoot() || !isAtomicRenameKey(
+ path.toUri().getPath()) || !path.toUri()
+ .getPath()
+ .endsWith(RenameAtomicity.SUFFIX)) {
+ return false;
+ }
+ try {
+ RenameAtomicity renameAtomicity
+ = getRedoRenameAtomicity(path, renamePendingJsonLen,
+ tracingContext, null);
+ renameAtomicity.redo();
+ } catch (AbfsRestOperationException ex) {
+ /*
+ * At this point, the source marked by the renamePending json file,
might have
+ * already got renamed by some parallel thread, or at this point, the
path
+ * would have got modified which would result in eTag change, which
would lead
+ * to a HTTP_CONFLICT. In this case, no more operation needs to be
taken, but
+ * since this is a renamePendingJson file and would be deleted by the
redo operation,
+ * the calling listPath should not return this json path as result.
+ */
+ if (ex.getStatusCode() != HttpURLConnection.HTTP_NOT_FOUND
+ && ex.getStatusCode() != HttpURLConnection.HTTP_CONFLICT) {
+ throw ex;
+ }
+ }
+ return true;
Review Comment:
why are we directly returning true here and not checking for
renameSrchasChanged as in the previous method ?
> ABFS: [FnsOverBlob] Implementing Rename and Delete APIs over Blob Endpoint
> --------------------------------------------------------------------------
>
> Key: HADOOP-19233
> URL: https://issues.apache.org/jira/browse/HADOOP-19233
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs/azure
> Affects Versions: 3.4.0
> Reporter: Anuj Modi
> Assignee: Anuj Modi
> Priority: Major
> Labels: pull-request-available
>
> Currently, we only support rename and delete operations on the DFS endpoint.
> The reason for supporting rename and delete operations on the Blob endpoint
> is that the Blob endpoint does not account for hierarchy. We need to ensure
> that the HDFS contracts are maintained when performing rename and delete
> operations. Renaming or deleting a directory over the Blob endpoint requires
> the client to handle the orchestration and rename or delete all the blobs
> within the specified directory.
>
> The task outlines the considerations for implementing rename and delete
> operations for the FNS-blob endpoint to ensure compatibility with HDFS
> contracts.
> * {*}Blob Endpoint Usage{*}: The task addresses the need for abstraction in
> the code to maintain HDFS contracts while performing rename and delete
> operations on the blob endpoint, which does not support hierarchy.
> * {*}Rename Operations{*}: The {{AzureBlobFileSystem#rename()}} method will
> use a {{RenameHandler}} instance to handle rename operations, with separate
> handlers for the DFS and blob endpoints. This method includes prechecks,
> destination adjustments, and orchestration of directory renaming for blobs.
> * {*}Atomic Rename{*}: Atomic renaming is essential for blob endpoints, as
> it requires orchestration to copy or delete each blob within the directory. A
> configuration will allow developers to specify directories for atomic
> renaming, with a JSON file to track the status of renames.
> * {*}Delete Operations{*}: Delete operations are simpler than renames,
> requiring fewer HDFS contract checks. For blob endpoints, the client must
> handle orchestration, including managing orphaned directories created by
> Az-copy.
> * {*}Orchestration for Rename/Delete{*}: Orchestration for rename and delete
> operations over blob endpoints involves listing blobs and performing actions
> on each blob. The process must be optimized to handle large numbers of blobs
> efficiently.
> * {*}Need for Optimization{*}: Optimization is crucial because the
> {{ListBlob}} API can return a maximum of 5000 blobs at once, necessitating
> multiple calls for large directories. The task proposes a producer-consumer
> model to handle blobs in parallel, thereby reducing processing time and
> memory usage.
> * {*}Producer-Consumer Design{*}: The proposed design includes a producer to
> list blobs, a queue to store the blobs, and a consumer to process them in
> parallel. This approach aims to improve efficiency and mitigate memory issues.
> More details will follow
> Perquisites for this Patch:
> 1. HADOOP-19187 ABFS: [FnsOverBlob]Making AbfsClient Abstract for supporting
> both DFS and Blob Endpoint - ASF JIRA (apache.org)
> 2. HADOOP-19226 ABFS: [FnsOverBlob]Implementing Azure Rest APIs on Blob
> Endpoint for AbfsBlobClient - ASF JIRA (apache.org)
> 3. HADOOP-19207 ABFS: [FnsOverBlob]Response Handling of Blob Endpoint APIs
> and Metadata APIs - ASF JIRA (apache.org)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]