Search in sources :

Example 1 with OMCancelDelegationTokenRequest

use of org.apache.hadoop.ozone.om.request.security.OMCancelDelegationTokenRequest 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;
    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 RevokeS3Secret:
            return new S3RevokeSecretRequest(omRequest);
        /**
         * Following key requests will be created in {@link OMKeyRequestFactory}.
         */
        case CreateDirectory:
        case CreateFile:
        case CreateKey:
        case AllocateBlock:
        case CommitKey:
        case DeleteKey:
        case DeleteKeys:
        case RenameKey:
        case RenameKeys:
        case PurgeKeys:
        case PurgePaths:
        case InitiateMultiPartUpload:
        case CommitMultiPartUpload:
        case AbortMultiPartUpload:
        case CompleteMultiPartUpload:
            return OMKeyRequestFactory.createRequest(omRequest, ozoneManager);
        default:
            throw new IllegalStateException("Unrecognized write command " + "type request" + cmdType);
    }
}
Also used : OMFinalizeUpgradeRequest(org.apache.hadoop.ozone.om.request.upgrade.OMFinalizeUpgradeRequest) 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) OMCancelPrepareRequest(org.apache.hadoop.ozone.om.request.upgrade.OMCancelPrepareRequest) S3GetSecretRequest(org.apache.hadoop.ozone.om.request.s3.security.S3GetSecretRequest) S3RevokeSecretRequest(org.apache.hadoop.ozone.om.request.s3.security.S3RevokeSecretRequest) BucketLayout(org.apache.hadoop.ozone.om.helpers.BucketLayout) OMBucketSetPropertyRequest(org.apache.hadoop.ozone.om.request.bucket.OMBucketSetPropertyRequest) OMVolumeCreateRequest(org.apache.hadoop.ozone.om.request.volume.OMVolumeCreateRequest) OMBucketDeleteRequest(org.apache.hadoop.ozone.om.request.bucket.OMBucketDeleteRequest) OMGetDelegationTokenRequest(org.apache.hadoop.ozone.om.request.security.OMGetDelegationTokenRequest) 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) OMRenewDelegationTokenRequest(org.apache.hadoop.ozone.om.request.security.OMRenewDelegationTokenRequest)

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 OMTrashRecoverRequest (org.apache.hadoop.ozone.om.request.key.OMTrashRecoverRequest)1 S3GetSecretRequest (org.apache.hadoop.ozone.om.request.s3.security.S3GetSecretRequest)1 S3RevokeSecretRequest (org.apache.hadoop.ozone.om.request.s3.security.S3RevokeSecretRequest)1 OMCancelDelegationTokenRequest (org.apache.hadoop.ozone.om.request.security.OMCancelDelegationTokenRequest)1 OMGetDelegationTokenRequest (org.apache.hadoop.ozone.om.request.security.OMGetDelegationTokenRequest)1 OMRenewDelegationTokenRequest (org.apache.hadoop.ozone.om.request.security.OMRenewDelegationTokenRequest)1 OMCancelPrepareRequest (org.apache.hadoop.ozone.om.request.upgrade.OMCancelPrepareRequest)1 OMFinalizeUpgradeRequest (org.apache.hadoop.ozone.om.request.upgrade.OMFinalizeUpgradeRequest)1 OMPrepareRequest (org.apache.hadoop.ozone.om.request.upgrade.OMPrepareRequest)1 OMVolumeCreateRequest (org.apache.hadoop.ozone.om.request.volume.OMVolumeCreateRequest)1 OMVolumeDeleteRequest (org.apache.hadoop.ozone.om.request.volume.OMVolumeDeleteRequest)1 OMVolumeSetOwnerRequest (org.apache.hadoop.ozone.om.request.volume.OMVolumeSetOwnerRequest)1 OMVolumeSetQuotaRequest (org.apache.hadoop.ozone.om.request.volume.OMVolumeSetQuotaRequest)1 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)1 ObjectType (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneObj.ObjectType)1