Class OMClientRequest
java.lang.Object
org.apache.hadoop.ozone.om.request.OMClientRequest
- All Implemented Interfaces:
RequestAuditor
- Direct Known Subclasses:
OMBucketAclRequest,OMBucketCreateRequest,OMBucketDeleteRequest,OMBucketSetOwnerRequest,OMBucketSetPropertyRequest,OMCancelDelegationTokenRequest,OMCancelPrepareRequest,OMEchoRPCWriteRequest,OMFinalizeUpgradeRequest,OMGetDelegationTokenRequest,OMKeyAclRequest,OMKeyRequest,OMPrefixAclRequest,OMPrepareRequest,OMQuotaRepairRequest,OMRenewDelegationTokenRequest,OMSetRangerServiceVersionRequest,OMSetSecretRequest,OMSnapshotCreateRequest,OMSnapshotDeleteRequest,OMSnapshotMoveDeletedKeysRequest,OMSnapshotMoveTableKeysRequest,OMSnapshotPurgeRequest,OMSnapshotRenameRequest,OMSnapshotSetPropertyRequest,OMTenantAssignAdminRequest,OMTenantAssignUserAccessIdRequest,OMTenantRevokeAdminRequest,OMTenantRevokeUserAccessIdRequest,OMVolumeRequest,S3GetSecretRequest,S3RevokeSecretRequest
OMClientRequest provides methods which every write OM request should
implement.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumStores the result of request execution in OMClientRequest#validateAndUpdateCache. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOMClientRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest omRequest) -
Method Summary
Modifier and TypeMethodDescriptionbuildAuditMessage(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap, Throwable throwable, org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfo userInfo) Build AuditMessage.buildVolumeAuditMap(String volume) Build auditMap with specified volume.voidcheckAcls(OzoneManager ozoneManager, org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType resType, org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType storeType, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType, String vol, String bucket, String key) Check Acls of ozone object.voidcheckAcls(OzoneManager ozoneManager, org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType resType, org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType storeType, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType, String vol, String bucket, String key, String volOwner) Check Acls of ozone object with volOwner given.voidcheckAcls(OzoneManager ozoneManager, org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType resType, org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType storeType, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType, String vol, String bucket, String key, String volOwner, String bucketOwner) Check Acls of ozone object with volOwner given.protected voidcheckACLsWithFSO(OzoneManager ozoneManager, String volumeName, String bucketName, String keyName, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType) Check Acls for the ozone key.protected org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponsecreateErrorOMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse.Builder omResponse, Exception ex) Set parameters needed for return error response to client.org.apache.hadoop.security.UserGroupInformationReturn UGI object created from OMRequest userInfo.org.apache.hadoop.security.UserGroupInformationCrete a UGI from request and wrap the AuthenticationException to OMException in case of empty credentials.Return String created from OMRequest userInfo.org.apache.hadoop.ozone.om.lock.OMLockDetailsorg.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequestReturn InetAddress created from OMRequest userInfo.org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfogetUserIfNotExists(OzoneManager ozoneManager) For non-rpc internal calls Server.getRemoteUser() and Server.getRemoteIp() will be null.org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfoGet User information which needs to be set in the OMRequest object.voidhandleRequestFailure(OzoneManager ozoneManager) Performs any request specific failure handling during request submission.static StringisValidKeyPath(String path) Whether the pathname is valid.protected voidmarkForAudit(org.apache.hadoop.ozone.audit.AuditLogger auditLogger, OMAuditLogger.Builder builder) Mark ready for log audit.voidmergeOmLockDetails(org.apache.hadoop.ozone.om.lock.OMLockDetails details) static StringnormalizeKeyPath(boolean enableFileSystemPaths, String keyPath, org.apache.hadoop.ozone.om.helpers.BucketLayout bucketLayout) Normalizes the key path based on the bucket layout.org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequestpreExecute(OzoneManager ozoneManager) Perform pre-execute steps on a OMRequest.voidsetUGI(org.apache.hadoop.security.UserGroupInformation ugi) static StringvalidateAndNormalizeKey(boolean enableFileSystemPaths, String keyName) static StringvalidateAndNormalizeKey(boolean enableFileSystemPaths, String keyPath, org.apache.hadoop.ozone.om.helpers.BucketLayout bucketLayout) static StringvalidateAndNormalizeKey(String keyName) validateAndUpdateCache(OzoneManager ozoneManager, long transactionLogIndex) For testing only.abstract OMClientResponsevalidateAndUpdateCache(OzoneManager ozoneManager, ExecutionContext context) Validate the OMRequest and update the cache.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.ozone.om.request.RequestAuditor
buildKeyArgsAuditMap, buildLightKeyArgsAuditMap
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
OMClientRequest
public OMClientRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest omRequest)
-
-
Method Details
-
getAuditBuilder
-
preExecute
public org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest preExecute(OzoneManager ozoneManager) throws IOException Perform pre-execute steps on a OMRequest. Called from the RPC context, and generates a OMRequest object which has all the information that will be either persisted in RocksDB or returned to the caller once this operation is executed.- Returns:
- OMRequest that will be serialized and handed off to Ratis for consensus.
- Throws:
IOException
-
handleRequestFailure
Performs any request specific failure handling during request submission. An example of this would be an undo of any steps taken during pre-execute. -
validateAndUpdateCache
public abstract OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, ExecutionContext context) Validate the OMRequest and update the cache. This step should verify that the request can be executed, perform any authorization steps and update the in-memory cache. This step does not persist the changes to the database. To coders and reviewers, CAUTION: Do NOT bring external dependencies into this method, doing so could potentially cause divergence in OM DB states in HA. If you have to, be extremely careful. e.g. Do NOT invoke ACL check inside validateAndUpdateCache, which can use Ranger plugin that relies on external DB.- Returns:
- the response that will be returned to the client.
-
validateAndUpdateCache
For testing only. -
getOmRequest
public org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest getOmRequest() -
getUserInfo
public org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfo getUserInfo() throws IOExceptionGet User information which needs to be set in the OMRequest object.- Returns:
- User Info.
- Throws:
IOException
-
getUserIfNotExists
public org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfo getUserIfNotExists(OzoneManager ozoneManager) throws IOException For non-rpc internal calls Server.getRemoteUser() and Server.getRemoteIp() will be null. Passing getCurrentUser() and Ip of the Om node that started it.- Returns:
- User Info.
- Throws:
IOException
-
checkAcls
public void checkAcls(OzoneManager ozoneManager, org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType resType, org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType storeType, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType, String vol, String bucket, String key) throws IOException Check Acls of ozone object.- Parameters:
ozoneManager-resType-storeType-aclType-vol-bucket-key-- Throws:
IOException
-
checkACLsWithFSO
protected void checkACLsWithFSO(OzoneManager ozoneManager, String volumeName, String bucketName, String keyName, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType) throws IOException Check Acls for the ozone key.- Parameters:
ozoneManager-volumeName-bucketName-keyName-- Throws:
IOException
-
checkAcls
public void checkAcls(OzoneManager ozoneManager, org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType resType, org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType storeType, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType, String vol, String bucket, String key, String volOwner) throws IOException Check Acls of ozone object with volOwner given.- Parameters:
ozoneManager-resType-storeType-aclType-vol-bucket-key-volOwner-- Throws:
IOException
-
checkAcls
public void checkAcls(OzoneManager ozoneManager, org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType resType, org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType storeType, org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType aclType, String vol, String bucket, String key, String volOwner, String bucketOwner) throws IOException Check Acls of ozone object with volOwner given.- Parameters:
ozoneManager-resType-storeType-aclType-vol-bucket-key-volOwner-bucketOwner-- Throws:
IOException
-
createUGI
public org.apache.hadoop.security.UserGroupInformation createUGI() throws org.apache.hadoop.security.authentication.client.AuthenticationExceptionReturn UGI object created from OMRequest userInfo. If userInfo is not set, returns null.- Returns:
- UserGroupInformation.
- Throws:
org.apache.hadoop.security.authentication.client.AuthenticationException
-
createUGIForApi
public org.apache.hadoop.security.UserGroupInformation createUGIForApi() throws org.apache.hadoop.ozone.om.exceptions.OMExceptionCrete a UGI from request and wrap the AuthenticationException to OMException in case of empty credentials.- Returns:
- UserGroupInformation
- Throws:
org.apache.hadoop.ozone.om.exceptions.OMException- exception about an empty user credential (unauthorized request)
-
setUGI
public void setUGI(org.apache.hadoop.security.UserGroupInformation ugi) -
getRemoteAddress
Return InetAddress created from OMRequest userInfo. If userInfo is not set, returns null.- Returns:
- InetAddress
- Throws:
IOException
-
getHostName
Return String created from OMRequest userInfo. If userInfo is not set, returns null.- Returns:
- String
-
createErrorOMResponse
protected org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse createErrorOMResponse(@Nonnull org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse.Builder omResponse, @Nonnull Exception ex) Set parameters needed for return error response to client.- Parameters:
omResponse-ex- - IOException- Returns:
- error response need to be returned to client - OMResponse.
-
markForAudit
protected void markForAudit(org.apache.hadoop.ozone.audit.AuditLogger auditLogger, OMAuditLogger.Builder builder) Mark ready for log audit.- Parameters:
auditLogger-builder-
-
buildAuditMessage
public OMAuditLogger.Builder buildAuditMessage(org.apache.hadoop.ozone.audit.AuditAction op, Map<String, String> auditMap, Throwable throwable, org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfo userInfo) Description copied from interface:RequestAuditorBuild AuditMessage.- Specified by:
buildAuditMessagein interfaceRequestAuditor- Parameters:
op-auditMap-throwable-userInfo-
-
buildVolumeAuditMap
Description copied from interface:RequestAuditorBuild auditMap with specified volume.- Specified by:
buildVolumeAuditMapin interfaceRequestAuditor- Parameters:
volume-- Returns:
- auditMap.
-
validateAndNormalizeKey
public static String validateAndNormalizeKey(boolean enableFileSystemPaths, String keyName) throws org.apache.hadoop.ozone.om.exceptions.OMException - Throws:
org.apache.hadoop.ozone.om.exceptions.OMException
-
normalizeKeyPath
public static String normalizeKeyPath(boolean enableFileSystemPaths, String keyPath, org.apache.hadoop.ozone.om.helpers.BucketLayout bucketLayout) throws org.apache.hadoop.ozone.om.exceptions.OMException Normalizes the key path based on the bucket layout. This should be used for existing keys. For new key creation, please seevalidateAndNormalizeKey(boolean, String, BucketLayout)- Returns:
- normalized key path
- Throws:
org.apache.hadoop.ozone.om.exceptions.OMException
-
validateAndNormalizeKey
public static String validateAndNormalizeKey(boolean enableFileSystemPaths, String keyPath, org.apache.hadoop.ozone.om.helpers.BucketLayout bucketLayout) throws org.apache.hadoop.ozone.om.exceptions.OMException - Throws:
org.apache.hadoop.ozone.om.exceptions.OMException
-
validateAndNormalizeKey
public static String validateAndNormalizeKey(String keyName) throws org.apache.hadoop.ozone.om.exceptions.OMException - Throws:
org.apache.hadoop.ozone.om.exceptions.OMException
-
isValidKeyPath
public static String isValidKeyPath(String path) throws org.apache.hadoop.ozone.om.exceptions.OMException Whether the pathname is valid. Check key names which contain a ":", ".", "..", "//", "". If it has any of these characters throws OMException, else return the path.- Throws:
org.apache.hadoop.ozone.om.exceptions.OMException
-
getOmLockDetails
public org.apache.hadoop.ozone.om.lock.OMLockDetails getOmLockDetails() -
mergeOmLockDetails
public void mergeOmLockDetails(org.apache.hadoop.ozone.om.lock.OMLockDetails details)
-