use of org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantRevokeUserAccessIdRequest in project ozone by apache.
the class OzoneManagerRatisUtils method createClientRequest.
/**
* Create OMClientRequest which encapsulates the OMRequest.
* @param omRequest
* @return OMClientRequest
* @throws IOException
*/
@SuppressWarnings("checkstyle:methodlength")
public static OMClientRequest createClientRequest(OMRequest omRequest, OzoneManager ozoneManager) throws IOException {
// Handling of exception by createClientRequest(OMRequest, OzoneManger):
// Either the code will take FSO or non FSO path, both classes has a
// validateAndUpdateCache() function which also contains
// validateBucketAndVolume() function which validates bucket and volume and
// throws necessary exceptions if required. validateAndUpdateCache()
// function has catch block which catches the exception if required and
// handles it appropriately.
Type cmdType = omRequest.getCmdType();
OzoneManagerProtocolProtos.KeyArgs keyArgs;
BucketLayout bucketLayout = BucketLayout.DEFAULT;
String volumeName = "";
String bucketName = "";
switch(cmdType) {
case CreateVolume:
return new OMVolumeCreateRequest(omRequest);
case SetVolumeProperty:
boolean hasQuota = omRequest.getSetVolumePropertyRequest().hasQuotaInBytes();
boolean hasOwner = omRequest.getSetVolumePropertyRequest().hasOwnerName();
Preconditions.checkState(hasOwner || hasQuota, "Either Quota or owner " + "should be set in the SetVolumeProperty request");
Preconditions.checkState(!(hasOwner && hasQuota), "Either Quota or " + "owner should be set in the SetVolumeProperty request. Should not " + "set both");
if (hasQuota) {
return new OMVolumeSetQuotaRequest(omRequest);
} else {
return new OMVolumeSetOwnerRequest(omRequest);
}
case DeleteVolume:
return new OMVolumeDeleteRequest(omRequest);
case CreateBucket:
return new OMBucketCreateRequest(omRequest);
case DeleteBucket:
return new OMBucketDeleteRequest(omRequest);
case SetBucketProperty:
boolean hasBucketOwner = omRequest.getSetBucketPropertyRequest().getBucketArgs().hasOwnerName();
if (hasBucketOwner) {
return new OMBucketSetOwnerRequest(omRequest);
} else {
return new OMBucketSetPropertyRequest(omRequest);
}
case AddAcl:
case RemoveAcl:
case SetAcl:
return getOMAclRequest(omRequest, ozoneManager);
case GetDelegationToken:
return new OMGetDelegationTokenRequest(omRequest);
case CancelDelegationToken:
return new OMCancelDelegationTokenRequest(omRequest);
case RenewDelegationToken:
return new OMRenewDelegationTokenRequest(omRequest);
case GetS3Secret:
return new S3GetSecretRequest(omRequest);
case RecoverTrash:
return new OMTrashRecoverRequest(omRequest);
case FinalizeUpgrade:
return new OMFinalizeUpgradeRequest(omRequest);
case Prepare:
return new OMPrepareRequest(omRequest);
case CancelPrepare:
return new OMCancelPrepareRequest(omRequest);
case SetS3Secret:
return new OMSetSecretRequest(omRequest);
case RevokeS3Secret:
return new S3RevokeSecretRequest(omRequest);
case PurgeKeys:
return new OMKeyPurgeRequest(omRequest);
case PurgeDirectories:
return new OMDirectoriesPurgeRequestWithFSO(omRequest);
case CreateTenant:
ozoneManager.checkS3MultiTenancyEnabled();
return new OMTenantCreateRequest(omRequest);
case DeleteTenant:
ozoneManager.checkS3MultiTenancyEnabled();
return new OMTenantDeleteRequest(omRequest);
case TenantAssignUserAccessId:
ozoneManager.checkS3MultiTenancyEnabled();
return new OMTenantAssignUserAccessIdRequest(omRequest);
case TenantRevokeUserAccessId:
ozoneManager.checkS3MultiTenancyEnabled();
return new OMTenantRevokeUserAccessIdRequest(omRequest);
case TenantAssignAdmin:
ozoneManager.checkS3MultiTenancyEnabled();
return new OMTenantAssignAdminRequest(omRequest);
case TenantRevokeAdmin:
ozoneManager.checkS3MultiTenancyEnabled();
return new OMTenantRevokeAdminRequest(omRequest);
case SetRangerServiceVersion:
return new OMSetRangerServiceVersionRequest(omRequest);
/*
* Key requests that can have multiple variants based on the bucket layout
* should be created using {@link BucketLayoutAwareOMKeyRequestFactory}.
*/
case CreateDirectory:
keyArgs = omRequest.getCreateDirectoryRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case CreateFile:
keyArgs = omRequest.getCreateFileRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case CreateKey:
keyArgs = omRequest.getCreateKeyRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case AllocateBlock:
keyArgs = omRequest.getAllocateBlockRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case CommitKey:
keyArgs = omRequest.getCommitKeyRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case DeleteKey:
keyArgs = omRequest.getDeleteKeyRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case DeleteKeys:
OzoneManagerProtocolProtos.DeleteKeyArgs deleteKeyArgs = omRequest.getDeleteKeysRequest().getDeleteKeys();
volumeName = deleteKeyArgs.getVolumeName();
bucketName = deleteKeyArgs.getBucketName();
break;
case RenameKey:
keyArgs = omRequest.getRenameKeyRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case RenameKeys:
OzoneManagerProtocolProtos.RenameKeysArgs renameKeysArgs = omRequest.getRenameKeysRequest().getRenameKeysArgs();
volumeName = renameKeysArgs.getVolumeName();
bucketName = renameKeysArgs.getBucketName();
break;
case InitiateMultiPartUpload:
keyArgs = omRequest.getInitiateMultiPartUploadRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case CommitMultiPartUpload:
keyArgs = omRequest.getCommitMultiPartUploadRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case AbortMultiPartUpload:
keyArgs = omRequest.getAbortMultiPartUploadRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
case CompleteMultiPartUpload:
keyArgs = omRequest.getCompleteMultiPartUploadRequest().getKeyArgs();
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
default:
throw new IllegalStateException("Unrecognized write command " + "type request" + cmdType);
}
return BucketLayoutAwareOMKeyRequestFactory.createRequest(volumeName, bucketName, omRequest, ozoneManager.getMetadataManager());
}
Aggregations