hemantk-12 commented on code in PR #4448:
URL: https://github.com/apache/ozone/pull/4448#discussion_r1152314281


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -462,6 +476,20 @@ public Response head(
     OzoneKey key;
     try {
       key = getClientProtocol().headS3Object(bucketName, keyPath);
+
+      /*
+        Necessary for directories in buckets with FSO layout.
+        Intended for apps which use Hadoop S3A.
+        Example of such app is Trino (through Hive connector).
+       */
+      boolean isFsoDirCreationEnabled = ozoneConfiguration
+          .getBoolean(OZONE_S3G_FSO_DIRECTORY_CREATION_ENABLED,
+              OZONE_S3G_FSO_DIRECTORY_CREATION_ENABLED_DEFAULT);
+      if (isFsoDirCreationEnabled &&
+          !key.isFile() &&
+          !keyPath.endsWith("/")) {
+        throw new OMException(ResultCodes.KEY_NOT_FOUND);
+      }

Review Comment:
   Lines 480-492 are duplicate of 321-334. Can be moved to a helper function.



##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKey.java:
##########
@@ -61,45 +60,38 @@ public class OzoneKey {
   private ReplicationConfig replicationConfig;
 
   private Map<String, String> metadata = new HashMap<>();
+
   /**
-   * Constructs OzoneKey from OmKeyInfo.
-   *
+   * Indicator if key is a file.
    */
-  @SuppressWarnings("parameternumber")
-  @Deprecated
-  public OzoneKey(String volumeName, String bucketName,
-                  String keyName, long size, long creationTime,
-                  long modificationTime, ReplicationType type,
-                  int replicationFactor) {
-    this(volumeName, bucketName, keyName, size, creationTime, modificationTime,
-            ReplicationConfig.fromTypeAndFactor(type,
-                    ReplicationFactor.valueOf(replicationFactor)));
-  }
+  private final boolean isFile;
 
   /**
    * Constructs OzoneKey from OmKeyInfo.
    *
    */
   @SuppressWarnings("parameternumber")
   public OzoneKey(String volumeName, String bucketName,
-                  String keyName, long size, long creationTime,
-                  long modificationTime, ReplicationConfig replicationConfig) {
+      String keyName, long size, long creationTime,
+      long modificationTime, ReplicationConfig replicationConfig,
+      boolean isFile) {
     this.volumeName = volumeName;
     this.bucketName = bucketName;
     this.name = keyName;
     this.dataSize = size;
     this.creationTime = Instant.ofEpochMilli(creationTime);
     this.modificationTime = Instant.ofEpochMilli(modificationTime);
     this.replicationConfig = replicationConfig;
+    this.isFile = isFile;
   }
 
   @SuppressWarnings("parameternumber")
   public OzoneKey(String volumeName, String bucketName,
-                  String keyName, long size, long creationTime,
-                  long modificationTime, ReplicationConfig replicationConfig,
-                  Map<String, String> metadata) {
+      String keyName, long size, long creationTime,

Review Comment:
   nit: I think it was properly indented previously. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to