rakeshadr commented on a change in pull request #2533:
URL: https://github.com/apache/ozone/pull/2533#discussion_r711914593
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/utils/OzoneManagerRatisUtils.java
##########
@@ -437,4 +450,117 @@ private static ServiceException
createLeaderNotReadyException(
return new ServiceException(leaderNotReadyException);
}
+ public static boolean isBucketFSOptimized(OMRequest omRequest,
+ OzoneManager ozoneManager) {
+ Type cmdType = omRequest.getCmdType();
+ BucketLayout bucketLayout = null;
+ OmBucketInfo buckInfo = null;
+ switch (cmdType) {
+ case AllocateBlock:
+ String volName =
+ omRequest.getAllocateBlockRequest().getKeyArgs().getVolumeName();
+ String buckName =
+ omRequest.getAllocateBlockRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case CreateKey:
+ volName = omRequest.getCreateKeyRequest().getKeyArgs().getVolumeName();
+ buckName = omRequest.getCreateKeyRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case CommitKey:
+ volName = omRequest.getCommitKeyRequest().getKeyArgs().getVolumeName();
+ buckName = omRequest.getCommitKeyRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case DeleteKey:
+ volName = omRequest.getDeleteKeyRequest().getKeyArgs().getVolumeName();
+ buckName = omRequest.getDeleteKeyRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case CreateFile:
+ volName = omRequest.getCreateFileRequest().getKeyArgs().getVolumeName();
+ buckName = omRequest.getCreateFileRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case CreateDirectory:
+ volName =
+ omRequest.getCreateDirectoryRequest().getKeyArgs().getVolumeName();
+ buckName =
+ omRequest.getCreateDirectoryRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case RenameKey:
+ volName = omRequest.getRenameKeyRequest().getKeyArgs().getVolumeName();
+ buckName = omRequest.getRenameKeyRequest().getKeyArgs().getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case InitiateMultiPartUpload:
+ volName = omRequest.getInitiateMultiPartUploadRequest().getKeyArgs()
+ .getVolumeName();
+ buckName = omRequest.getInitiateMultiPartUploadRequest().getKeyArgs()
+ .getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case CommitMultiPartUpload:
+ volName = omRequest.getCommitMultiPartUploadRequest().getKeyArgs()
+ .getVolumeName();
+ buckName = omRequest.getCommitMultiPartUploadRequest().getKeyArgs()
+ .getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case AbortMultiPartUpload:
+ volName = omRequest.getAbortMultiPartUploadRequest().getKeyArgs()
+ .getVolumeName();
+ buckName = omRequest.getAbortMultiPartUploadRequest().getKeyArgs()
+ .getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ case CompleteMultiPartUpload:
+ volName = omRequest.getCompleteMultiPartUploadRequest().getKeyArgs()
+ .getVolumeName();
+ buckName = omRequest.getCompleteMultiPartUploadRequest().getKeyArgs()
+ .getBucketName();
+ buckInfo = getOmBucketInfo(ozoneManager, buckInfo, volName, buckName);
+ bucketLayout = getBucketLayout(buckInfo);
+ break;
+ default:
+ break;
+ }
+ return BucketLayout.FILE_SYSTEM_OPTIMIZED.equals(bucketLayout);
+ }
+
+ private static OmBucketInfo getOmBucketInfo(OzoneManager ozoneManager,
+ OmBucketInfo buckInfo, String volName, String buckName) {
+ String buckKey =
Review comment:
Thanks @bharatviswa504 for the offline discussion.
@aryangupta1998 Here all the client requests are executed in sequential
model, so not required to acquire a BUCKET_LOCK. All the client requests are
executed through `OzoneManagerStateMachine#runCommand` function and ensures
sequential execution path.
Below is the call trace to perform OM client request operation:
`OzoneManagerStateMachine#applyTransaction ->
OzoneManagerStateMachine#runCommand ->
OzoneManagerRequestHandler#handleWriteRequest ->
OzoneManagerRatisUtils#createClientRequest ->
OzoneManagerRatisUtils#getOmBucketInfo ->
omMetadataManager().getBucketTable().get(buckKey)`
@aryangupta1998 could you please add java comment about this part.
--
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]