Class AuthorizerLockImpl
java.lang.Object
org.apache.hadoop.ozone.om.multitenant.AuthorizerLockImpl
- All Implemented Interfaces:
AuthorizerLock
Implementation of
AuthorizerLock.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the authorizer write lock is held by the current thread.longlongtryReadLock(long timeout) Attempt to acquire the read lock to the authorizer with a timeout.longtryWriteLock(long timeout) Attempt to acquire the write lock to authorizer with a timeout.voidA wrapper around tryWriteLockThrowOnTimeout() that is used exclusively in OMRequests.longA wrapper around tryWriteLock() that throws when timed out.voidunlockRead(long stamp) Release read lock on the authorizer.voidunlockWrite(long stamp) Release read lock on the authorizer.voidA wrapper around unlockWrite() that is used exclusively in OMRequests.booleanvalidateOptimisticRead(long stamp)
-
Constructor Details
-
AuthorizerLockImpl
public AuthorizerLockImpl()
-
-
Method Details
-
tryReadLock
Description copied from interface:AuthorizerLockAttempt to acquire the read lock to the authorizer with a timeout.- Specified by:
tryReadLockin interfaceAuthorizerLock- Returns:
- stamp returned from lock op. required when releasing the lock
- Throws:
InterruptedException
-
unlockRead
public void unlockRead(long stamp) Release read lock on the authorizer. This is only used by BG sync at the moment.- Specified by:
unlockReadin interfaceAuthorizerLock
-
tryOptimisticReadThrowOnTimeout
- Specified by:
tryOptimisticReadThrowOnTimeoutin interfaceAuthorizerLock- Returns:
- stamp that can be passed to
AuthorizerLock.validateOptimisticRead(long)to check if a write lock was acquired since the stamp was issued. - Throws:
IOException- If an ongoing write prevents the lock from moving to the read state for longer than the timeout.
-
validateOptimisticRead
public boolean validateOptimisticRead(long stamp) - Specified by:
validateOptimisticReadin interfaceAuthorizerLock- Returns:
- True if the write lock was not acquired since this stamp was issued for an optimistic read. False otherwise.
-
tryWriteLock
Description copied from interface:AuthorizerLockAttempt to acquire the write lock to authorizer with a timeout.- Specified by:
tryWriteLockin interfaceAuthorizerLock- Returns:
- stamp
- Throws:
InterruptedException
-
unlockWrite
public void unlockWrite(long stamp) Release read lock on the authorizer. This is used by both BG sync and tenant requests.- Specified by:
unlockWritein interfaceAuthorizerLock
-
tryWriteLockThrowOnTimeout
Description copied from interface:AuthorizerLockA wrapper around tryWriteLock() that throws when timed out.- Specified by:
tryWriteLockThrowOnTimeoutin interfaceAuthorizerLock- Returns:
- stamp
- Throws:
IOException
-
tryWriteLockInOMRequest
Description copied from interface:AuthorizerLockA wrapper around tryWriteLockThrowOnTimeout() that is used exclusively in OMRequests. MUST use paired with unlockWriteInOMRequest() for unlocking to ensure correctness.- Specified by:
tryWriteLockInOMRequestin interfaceAuthorizerLock- Throws:
IOException
-
unlockWriteInOMRequest
public void unlockWriteInOMRequest()Description copied from interface:AuthorizerLockA wrapper around unlockWrite() that is used exclusively in OMRequests.- Specified by:
unlockWriteInOMRequestin interfaceAuthorizerLock
-
isWriteLockHeldByCurrentThread
public boolean isWriteLockHeldByCurrentThread()Description copied from interface:AuthorizerLockReturns true if the authorizer write lock is held by the current thread. Used inOMMultiTenantManagerImpl.AuthorizerOp.- Specified by:
isWriteLockHeldByCurrentThreadin interfaceAuthorizerLock
-