adoroszlai commented on code in PR #7566:
URL: https://github.com/apache/ozone/pull/7566#discussion_r1886570138


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -1373,4 +1376,109 @@ protected void validateEncryptionKeyInfo(OmBucketInfo 
bucketInfo, KeyArgs keyArg
           keyArgs.getKeyName() + " in encrypted bucket " + 
keyArgs.getBucketName(), INVALID_REQUEST);
     }
   }
+
+  protected void addMissingParentsToCache(OmBucketInfo omBucketInfo,
+                                          List<OmDirectoryInfo> 
missingParentInfos,
+                                          OMMetadataManager omMetadataManager,
+                                          long volumeId,
+                                          long bucketId,
+                                          long transactionLogIndex) throws 
IOException {
+
+    // validate and update namespace for missing parent directory.
+    checkBucketQuotaInNamespace(omBucketInfo, missingParentInfos.size());
+    omBucketInfo.incrUsedNamespace(missingParentInfos.size());
+
+    // Add cache entries for the missing parent directories.
+    OMFileRequest.addDirectoryTableCacheEntries(omMetadataManager,
+            volumeId, bucketId, transactionLogIndex,
+            missingParentInfos, null);
+  }
+
+  protected OmKeyInfo getOmKeyInfoFromOpenKeyTable(String dbMultipartKey,
+                                                   String keyName,
+                                                   OMMetadataManager 
omMetadataManager) throws IOException {
+    return omMetadataManager.getOpenKeyTable(getBucketLayout())
+            .get(dbMultipartKey);
+  }
+
+  protected void addMultiPartToCache(
+          OMMetadataManager omMetadataManager, String multipartOpenKey,
+          OMFileRequest.OMPathInfoWithFSO pathInfoFSO, OmKeyInfo omKeyInfo,
+          String keyName, long transactionLogIndex
+  ) {
+
+    // Add multi part to cache
+    OMFileRequest.addOpenFileTableCacheEntry(omMetadataManager,
+            multipartOpenKey, omKeyInfo, pathInfoFSO.getLeafNodeName(),
+            keyName, transactionLogIndex);
+
+  }
+
+  protected List<OmDirectoryInfo> addMissingDirectories(OzoneManager 
ozoneManager,
+                                                        
OzoneManagerProtocolProtos.KeyArgs keyArgs,
+                                                        long trxnLogIndex) 
throws
+          IOException {
+    OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
+    final String volumeName = keyArgs.getVolumeName();
+    final String bucketName = keyArgs.getBucketName();
+    final String keyName = keyArgs.getKeyName();
+    OmBucketInfo omBucketInfo = getBucketInfo(omMetadataManager,
+            volumeName, bucketName);
+    List<OmDirectoryInfo> missingParentInfos;
+    OMFileRequest.OMPathInfoWithFSO pathInfoFSO = OMFileRequest
+            .verifyDirectoryKeysInPath(omMetadataManager, volumeName, 
bucketName,
+                    keyName, Paths.get(keyName));
+    missingParentInfos = getAllMissingParentDirInfo(ozoneManager, keyArgs, 
omBucketInfo,
+                    pathInfoFSO, trxnLogIndex);
+
+    if (missingParentInfos != null && !missingParentInfos.isEmpty()) {
+      final long volumeId = omMetadataManager.getVolumeId(volumeName);
+      final long bucketId = omMetadataManager.getBucketId(volumeName,
+              bucketName);
+
+      // add all missing parents to directory table
+      addMissingParentsToCache(omBucketInfo, missingParentInfos,
+              omMetadataManager, volumeId, bucketId, trxnLogIndex);
+
+      String multipartOpenKey = omMetadataManager
+              .getMultipartKey(volumeId, bucketId,
+                      pathInfoFSO.getLastKnownParentId(),
+                      pathInfoFSO.getLeafNodeName(),
+                      keyArgs.getMultipartUploadID());

Review Comment:
   nit: Please indent continuations with 4 spaces, not 8.  (Applies to the 
patch as a whole, this is only an example.)
   
   



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/multipart/S3MultipartUploadCompleteRequest.java:
##########
@@ -546,22 +476,6 @@ protected String getDBOzoneKey(OMMetadataManager 
omMetadataManager,
     return omMetadataManager.getOzoneKey(volumeName, bucketName, keyName);
   }
 
-  protected void addMissingParentsToCache(OmBucketInfo omBucketInfo,
-      List<OmDirectoryInfo> missingParentInfos,
-      OMMetadataManager omMetadataManager,
-      long volumeId, long bucketId, long transactionLogIndex
-  ) throws IOException {
-    // FSO is disabled. Do nothing.
-  }
-
-  protected void addMultiPartToCache(
-      OMMetadataManager omMetadataManager, String multipartOpenKey,
-      OMFileRequest.OMPathInfoWithFSO pathInfoFSO, OmKeyInfo omKeyInfo,
-      String keyName, long transactionLogIndex
-  ) throws IOException {
-    // FSO is disabled. Do nothing.
-  }

Review Comment:
   This used to do nothing for non-FSO, and was overridden to add the missing 
parents only for FSO.  I may be missing something, but it seems the patch does 
not distinguish between these two cases.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/multipart/S3MultipartUploadCompleteRequest.java:
##########
@@ -18,36 +18,22 @@
 
 package org.apache.hadoop.ozone.om.request.s3.multipart;
 
+import jakarta.annotation.Nullable;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
-
-import java.io.IOException;
-import java.nio.file.InvalidPathException;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiFunction;

Review Comment:
   Please do not reorder imports unnecessarily.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -1373,4 +1376,109 @@ protected void validateEncryptionKeyInfo(OmBucketInfo 
bucketInfo, KeyArgs keyArg
           keyArgs.getKeyName() + " in encrypted bucket " + 
keyArgs.getBucketName(), INVALID_REQUEST);
     }
   }
+
+  protected void addMissingParentsToCache(OmBucketInfo omBucketInfo,
+                                          List<OmDirectoryInfo> 
missingParentInfos,
+                                          OMMetadataManager omMetadataManager,
+                                          long volumeId,
+                                          long bucketId,
+                                          long transactionLogIndex) throws 
IOException {

Review Comment:
   Please do not format method signature like this.  Whenever visibility / 
return type / method name / other modifiers are changed, we would have to 
reindent all parameters.



-- 
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