Search in sources :

Example 1 with OMDirectoriesPurgeRequestWithFSO

use of org.apache.hadoop.ozone.om.request.key.OMDirectoriesPurgeRequestWithFSO 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());
}
Also used : OMFinalizeUpgradeRequest(org.apache.hadoop.ozone.om.request.upgrade.OMFinalizeUpgradeRequest) OMKeyPurgeRequest(org.apache.hadoop.ozone.om.request.key.OMKeyPurgeRequest) OMCancelPrepareRequest(org.apache.hadoop.ozone.om.request.upgrade.OMCancelPrepareRequest) OMSetSecretRequest(org.apache.hadoop.ozone.om.request.s3.security.OMSetSecretRequest) OMTenantDeleteRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantDeleteRequest) OMTenantRevokeUserAccessIdRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantRevokeUserAccessIdRequest) S3GetSecretRequest(org.apache.hadoop.ozone.om.request.s3.security.S3GetSecretRequest) S3RevokeSecretRequest(org.apache.hadoop.ozone.om.request.s3.security.S3RevokeSecretRequest) OMTenantRevokeAdminRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantRevokeAdminRequest) OMTenantAssignUserAccessIdRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantAssignUserAccessIdRequest) OMBucketSetPropertyRequest(org.apache.hadoop.ozone.om.request.bucket.OMBucketSetPropertyRequest) OMVolumeCreateRequest(org.apache.hadoop.ozone.om.request.volume.OMVolumeCreateRequest) OMGetDelegationTokenRequest(org.apache.hadoop.ozone.om.request.security.OMGetDelegationTokenRequest) OMSetRangerServiceVersionRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMSetRangerServiceVersionRequest) OMTenantAssignAdminRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantAssignAdminRequest) OMTenantCreateRequest(org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantCreateRequest) OMRenewDelegationTokenRequest(org.apache.hadoop.ozone.om.request.security.OMRenewDelegationTokenRequest) OMTrashRecoverRequest(org.apache.hadoop.ozone.om.request.key.OMTrashRecoverRequest) OMBucketCreateRequest(org.apache.hadoop.ozone.om.request.bucket.OMBucketCreateRequest) OMVolumeSetOwnerRequest(org.apache.hadoop.ozone.om.request.volume.OMVolumeSetOwnerRequest) OMDirectoriesPurgeRequestWithFSO(org.apache.hadoop.ozone.om.request.key.OMDirectoriesPurgeRequestWithFSO) BucketLayout(org.apache.hadoop.ozone.om.helpers.BucketLayout) OMBucketDeleteRequest(org.apache.hadoop.ozone.om.request.bucket.OMBucketDeleteRequest) ObjectType(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneObj.ObjectType) Type(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type) OMVolumeSetQuotaRequest(org.apache.hadoop.ozone.om.request.volume.OMVolumeSetQuotaRequest) OzoneManagerProtocolProtos(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos) OMVolumeDeleteRequest(org.apache.hadoop.ozone.om.request.volume.OMVolumeDeleteRequest) OMCancelDelegationTokenRequest(org.apache.hadoop.ozone.om.request.security.OMCancelDelegationTokenRequest) OMPrepareRequest(org.apache.hadoop.ozone.om.request.upgrade.OMPrepareRequest) OMBucketSetOwnerRequest(org.apache.hadoop.ozone.om.request.bucket.OMBucketSetOwnerRequest)

Aggregations

BucketLayout (org.apache.hadoop.ozone.om.helpers.BucketLayout)1 OMBucketCreateRequest (org.apache.hadoop.ozone.om.request.bucket.OMBucketCreateRequest)1 OMBucketDeleteRequest (org.apache.hadoop.ozone.om.request.bucket.OMBucketDeleteRequest)1 OMBucketSetOwnerRequest (org.apache.hadoop.ozone.om.request.bucket.OMBucketSetOwnerRequest)1 OMBucketSetPropertyRequest (org.apache.hadoop.ozone.om.request.bucket.OMBucketSetPropertyRequest)1 OMDirectoriesPurgeRequestWithFSO (org.apache.hadoop.ozone.om.request.key.OMDirectoriesPurgeRequestWithFSO)1 OMKeyPurgeRequest (org.apache.hadoop.ozone.om.request.key.OMKeyPurgeRequest)1 OMTrashRecoverRequest (org.apache.hadoop.ozone.om.request.key.OMTrashRecoverRequest)1 OMSetSecretRequest (org.apache.hadoop.ozone.om.request.s3.security.OMSetSecretRequest)1 S3GetSecretRequest (org.apache.hadoop.ozone.om.request.s3.security.S3GetSecretRequest)1 S3RevokeSecretRequest (org.apache.hadoop.ozone.om.request.s3.security.S3RevokeSecretRequest)1 OMSetRangerServiceVersionRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMSetRangerServiceVersionRequest)1 OMTenantAssignAdminRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantAssignAdminRequest)1 OMTenantAssignUserAccessIdRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantAssignUserAccessIdRequest)1 OMTenantCreateRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantCreateRequest)1 OMTenantDeleteRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantDeleteRequest)1 OMTenantRevokeAdminRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantRevokeAdminRequest)1 OMTenantRevokeUserAccessIdRequest (org.apache.hadoop.ozone.om.request.s3.tenant.OMTenantRevokeUserAccessIdRequest)1 OMCancelDelegationTokenRequest (org.apache.hadoop.ozone.om.request.security.OMCancelDelegationTokenRequest)1 OMGetDelegationTokenRequest (org.apache.hadoop.ozone.om.request.security.OMGetDelegationTokenRequest)1