[
https://issues.apache.org/jira/browse/HADOOP-19448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17924173#comment-17924173
]
ASF GitHub Bot commented on HADOOP-19448:
-----------------------------------------
anmolanmol1234 commented on code in PR #7353:
URL: https://github.com/apache/hadoop/pull/7353#discussion_r1943343123
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java:
##########
@@ -555,58 +545,254 @@ public AbfsRestOperation createPath(final String path,
final AbfsRestOperation op = getAbfsRestOperation(
AbfsRestOperationType.PutBlob,
HTTP_METHOD_PUT, url, requestHeaders);
+ op.execute(tracingContext);
+ return op;
+ }
+
+ /**
+ * Checks if the specified path is a directory by listing its contents.
+ *
+ * @param path the path to check.
+ * @param tracingContext the tracing context for the service call.
+ * @return true if the path is a directory and contains entries, false
otherwise.
+ * @throws AzureBlobFileSystemException if the rest operation fails.
+ */
+ private boolean checkDirectoryByList(String path,
+ TracingContext tracingContext)
+ throws AzureBlobFileSystemException {
+ AbfsRestOperation listPathOp = listPath(path, false, 1, null,
+ tracingContext, false);
+ AbfsHttpOperation listPathResult = listPathOp.getResult();
+ if (listPathResult != null) {
+ // Determine if the path is a directory by checking if the list result
schema has any paths
+ return !listPathResult.getListResultSchema().paths().isEmpty();
+ }
+ return false;
+ }
+
+ /**
+ * Checks if the specified path exists as a directory.
+ *
+ * @param path the path of the directory to check.
+ * @param tracingContext the tracing context for the service call.
+ * @return true if the directory exists, false otherwise.
+ * @throws AzureBlobFileSystemException if the rest operation fails.
+ */
+ private boolean checkForDirectoryExistence(String path,
+ TracingContext tracingContext)
+ throws AzureBlobFileSystemException {
+ // Check if the directory contains any entries by listing its contents.
+ if (checkDirectoryByList(path, tracingContext)) {
Review Comment:
We dont want or condition here, we first want to check for dir using list
and if that doesnt return entries only then we want to check for empty explicit
dir, hence sequential flow
> ABFS: [FnsOverBlob][Optimizations] Reduce Network Calls In Create and Mkdir
> Flow
> --------------------------------------------------------------------------------
>
> Key: HADOOP-19448
> URL: https://issues.apache.org/jira/browse/HADOOP-19448
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs/azure
> Affects Versions: 3.4.2
> Reporter: Anuj Modi
> Assignee: Anmol Asrani
> Priority: Major
> Labels: pull-request-available
>
> Implementing Create and Mkdir file system APIs for FNS(HNS Disabled) accounts
> on Blob Endpoint involves a lot of checks and marker file creations to handle
> implicit explicit cases of paths involved in these APIs.
> This Jira proposes a few optimizations to reduce the network calls wherever
> possible and in case where create/mkdir is bound to fail, it should fail
> faster before doing any post checks,
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]