arp7 commented on a change in pull request #1196:
URL: https://github.com/apache/hadoop-ozone/pull/1196#discussion_r453775722
##########
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:
@bharatviswa504 , one q. We are adding cache entries right away instead
of at the end on success. Could this be a potential issue on the failure path?
----------------------------------------------------------------
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]