use of org.apache.hadoop.ozone.om.request.volume.OMVolumeDeleteRequest 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);
}
}
Aggregations