Interface FSNLockManager
- All Known Implementing Classes:
FineGrainedFSNamesystemLock,GlobalFSNamesystemLock
public interface FSNLockManager
-
Method Summary
Modifier and TypeMethodDescriptionlonggetNumOfReadLockLongHold(RwLockMode lockMode) Returns the number of time the read lock has been held longer than the threshold.longgetNumOfWriteLockLongHold(RwLockMode lockMode) Returns the number of time the write-lock has been held longer than the threshold.intgetQueueLength(RwLockMode lockMode) Returns the QueueLength of waiting threads.intgetReadHoldCount(RwLockMode lockMode) Queries the number of reentrant read holds on this lock by the current thread.longTry to get the reporting threshold of the read lock.longTry to get the reporting threshold for the write lock.booleanhasReadLock(RwLockMode lockMode) Check if the current thread holds read lock according to the lock mode.booleanhasWriteLock(RwLockMode lockMode) Check if the current thread holds write lock according to the lock mode.booleanCheck if the metrics is enabled.voidreadLock(RwLockMode lockMode) Acquire read lock for an operation according to the lock mode.voidreadLockInterruptibly(RwLockMode lockMode) Acquire read lock according to the lock mode, unless interrupted while waiting.voidreadUnlock(RwLockMode lockMode, String opName) Release read lock for the operation according to the lock mode.voidreadUnlock(RwLockMode lockMode, String opName, Supplier<String> lockReportInfoSupplier) Release read lock for the operation according to the lock mode.voidvoidsetMetricsEnabled(boolean metricsEnabled) Reset the metricsEnabled according to the lock mode.voidsetReadLockReportingThresholdMs(long readLockReportingThresholdMs) Try to set the reporting threshold of the read lock.voidsetWriteLockReportingThresholdMs(long writeLockReportingThresholdMs) Try to set the reporting threshold for the write lock.voidwriteLock(RwLockMode lockMode) Acquire write lock for an operation according to the lock mode.voidwriteLockInterruptibly(RwLockMode lockMode) voidwriteUnlock(RwLockMode lockMode, String opName) Release write lock for the operation according to the lock mode.voidwriteUnlock(RwLockMode lockMode, String opName, boolean suppressWriteLockReport) Release write lock for the operation according to the lock mode.voidwriteUnlock(RwLockMode lockMode, String opName, Supplier<String> lockReportInfoSupplier) Release write lock for the operation according to the lock mode.
-
Method Details
-
readLock
Acquire read lock for an operation according to the lock mode.- Parameters:
lockMode- locking mode
-
readLockInterruptibly
Acquire read lock according to the lock mode, unless interrupted while waiting.- Parameters:
lockMode- locking mode- Throws:
InterruptedException- If the thread is interrupted, an InterruptedException is thrown.
-
readUnlock
Release read lock for the operation according to the lock mode.- Parameters:
lockMode- locking modeopName- operation name
-
readUnlock
Release read lock for the operation according to the lock mode.- Parameters:
lockMode- locking modeopName- operation namelockReportInfoSupplier- supplier used to report some information for this lock.
-
writeLock
Acquire write lock for an operation according to the lock mode.- Parameters:
lockMode- locking mode
-
writeUnlock
Release write lock for the operation according to the lock mode.- Parameters:
lockMode- locking modeopName- operation name
-
writeUnlock
Release write lock for the operation according to the lock mode.- Parameters:
lockMode- locking modeopName- operation namesuppressWriteLockReport- When false, event of write lock being held for long time will be logged in logs and metrics.
-
writeUnlock
Release write lock for the operation according to the lock mode.- Parameters:
lockMode- locking modeopName- operation namelockReportInfoSupplier- supplier used to report information for this lock.
-
writeLockInterruptibly
- Throws:
InterruptedException
-
hasWriteLock
Check if the current thread holds write lock according to the lock mode.- Parameters:
lockMode- locking mode- Returns:
- true if the current thread is holding the write-lock, else false.
-
hasReadLock
Check if the current thread holds read lock according to the lock mode.- Parameters:
lockMode- locking mode- Returns:
- true if the current thread is holding the read-lock, else false.
-
getReadHoldCount
Queries the number of reentrant read holds on this lock by the current thread. A reader thread has a hold on a lock for each lock action that is not matched by an unlock action.- Parameters:
lockMode- locking mode- Returns:
- the number of holds on the read lock by the current thread, or zero if the read lock is not held by the current thread
-
getQueueLength
Returns the QueueLength of waiting threads. A larger number indicates greater lock contention.- Parameters:
lockMode- locking mode- Returns:
- int - Number of threads waiting on this lock
-
getNumOfReadLockLongHold
Returns the number of time the read lock has been held longer than the threshold.- Parameters:
lockMode- locking mode- Returns:
- long - Number of time the read lock has been held longer than the threshold
-
getNumOfWriteLockLongHold
Returns the number of time the write-lock has been held longer than the threshold.- Parameters:
lockMode- locking mode- Returns:
- long - Number of time the write-lock has been held longer than the threshold.
-
isMetricsEnabled
boolean isMetricsEnabled()Check if the metrics is enabled.- Returns:
- true if the metrics is enabled, else false.
-
setMetricsEnabled
void setMetricsEnabled(boolean metricsEnabled) Reset the metricsEnabled according to the lock mode.- Parameters:
metricsEnabled- the new metricsEnabled
-
setReadLockReportingThresholdMs
void setReadLockReportingThresholdMs(long readLockReportingThresholdMs) Try to set the reporting threshold of the read lock.- Parameters:
readLockReportingThresholdMs- reporting threshold
-
getReadLockReportingThresholdMs
long getReadLockReportingThresholdMs()Try to get the reporting threshold of the read lock.- Returns:
- the reporting threshold.
-
setWriteLockReportingThresholdMs
void setWriteLockReportingThresholdMs(long writeLockReportingThresholdMs) Try to set the reporting threshold for the write lock.- Parameters:
writeLockReportingThresholdMs- reporting threshold.
-
getWriteLockReportingThresholdMs
long getWriteLockReportingThresholdMs()Try to get the reporting threshold for the write lock.- Returns:
- reporting threshold.
-
setLockForTests
-
getLockForTests
-