[ 
https://issues.apache.org/jira/browse/HADOOP-19795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18055124#comment-18055124
 ] 

ASF GitHub Bot commented on HADOOP-19795:
-----------------------------------------

anmolanmol1234 commented on code in PR #8212:
URL: https://github.com/apache/hadoop/pull/8212#discussion_r2741062025


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java:
##########
@@ -599,9 +672,45 @@ int readRemote(long position, byte[] b, int offset, int 
length, TracingContext t
     } catch (AzureBlobFileSystemException ex) {
       if (ex instanceof AbfsRestOperationException) {
         AbfsRestOperationException ere = (AbfsRestOperationException) ex;
-        if (ere.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
-          throw new FileNotFoundException(ere.getMessage());
+        int status = ere.getStatusCode();
+        if(ere.getErrorMessage().contains(readOnDirectoryErrorMsg)){
+          throw ere;
+        }
+        boolean isHnsEnabled = client.getIsNamespaceEnabled();
+
+        // Case-1: 404 NOT FOUND
+        if (status == HttpURLConnection.HTTP_NOT_FOUND) {
+          /*
+           * If HNS account or restrictGpsOnOpenFile disabled,
+           * we dont need any further checks
+          */
+          if (isHnsEnabled || !shouldRestrictGpsOnOpenFile()) {
+            throw new FileNotFoundException(ere.getMessage());
+          }
+
+          // FNS account with restrictGpsOnOpenFile enabled
+          try {
+            // Need to rule out if the path is an implicit directory
+            checkIfDirPathInFNS();
+
+          } catch (AzureBlobFileSystemException gpsEx) {
+            AbfsRestOperationException gpsEre = (AbfsRestOperationException) 
gpsEx;
+            if(gpsEre.getErrorMessage().contains(readOnDirectoryErrorMsg)){
+              throw gpsEre;
+            }
+            // The file does not exist
+            else throw new FileNotFoundException(gpsEre.getMessage());
+          }
+        }
+
+        // Case-2: 416 INVALID RANGE
+        if (!isHnsEnabled && INVALID_RANGE.equals(ere.getErrorCode())) {
+          // Need to rule out if the path is an explicit directory
+          checkIfDirPathInFNS();
         }
+
+        // Default: propagate original error
+        throw new IOException(ex);

Review Comment:
   should be done once only on line 715





> ABFS: GetPathStatus Optimization on OpenFileForRead
> ---------------------------------------------------
>
>                 Key: HADOOP-19795
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19795
>             Project: Hadoop Common
>          Issue Type: Task
>          Components: fs/azure
>    Affects Versions: 3.4.1, 3.4.2
>            Reporter: Manika Joshi
>            Assignee: Manika Joshi
>            Priority: Major
>              Labels: pull-request-available
>
> We do a getPathStatus call during file open for read. This call is primarily 
> used to fetch the file’s metadata properties before the actual read begins. 
> We are now introducing an optional, config-driven read flow that avoids the 
> getPathStatus call during open and instead derives required metadata from the 
> read response itself. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to