bharatviswa504 commented on a change in pull request #1196:
URL: https://github.com/apache/hadoop-ozone/pull/1196#discussion_r454001878



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCreateRequest.java
##########
@@ -221,8 +233,45 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager,
       OmBucketInfo bucketInfo = omMetadataManager.getBucketTable().get(
           omMetadataManager.getBucketKey(volumeName, bucketName));
 
+      boolean createIntermediateDir =
+          ozoneManager.getConfiguration().getBoolean(
+              OZONE_OM_CREATE_INTERMEDIATE_DIRECTORY,
+              OZONE_OM_CREATE_INTERMEDIATE_DIRECTORY_DEFAULT);
+
+      // If FILE_EXISTS we just override like how we used to do for Key Create.
+      List< OzoneAcl > inheritAcls;
+      if (createIntermediateDir) {
+        OMFileRequest.OMPathInfo pathInfo =
+            OMFileRequest.verifyFilesInPath(omMetadataManager, volumeName,
+                bucketName, keyName, Paths.get(keyName));
+        OMFileRequest.OMDirectoryResult omDirectoryResult =
+            pathInfo.getDirectoryResult();
+        inheritAcls = pathInfo.getAcls();
+
+        // Check if a file or directory exists with same key name.
+        if (omDirectoryResult == DIRECTORY_EXISTS) {
+          throw new OMException("Can not write to directory: " + keyName,
+              NOT_A_FILE);
+        } else
+          if (omDirectoryResult == FILE_EXISTS_IN_GIVENPATH) {
+            throw new OMException("Can not create file: " + keyName +
+                " as there is already file in the given path", NOT_A_FILE);
+          }
+
+        missingParentInfos = OMDirectoryCreateRequest
+            .getAllParentInfo(ozoneManager, keyArgs,
+                pathInfo.getMissingParents(), inheritAcls, trxnLogIndex);
+
+        // Add cache entries for the prefix directories.

Review comment:
       Yes, there will be some intermediate directories left in DB, key commit 
failed. There will be intermediate directories created.
   But I don't see that causing an issue. But cleaner thing is cleaning up 
entries. 
   But this is a common issue for FileCreate and KeyCreate.
   
   And in the case lets say key create itself failed in DB flush, we terminate 
DB.




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

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