Interface FSNLockManager

All Known Implementing Classes:
FineGrainedFSNamesystemLock, GlobalFSNamesystemLock

public interface FSNLockManager
  • Method Details

    • readLock

      void readLock(RwLockMode lockMode)
      Acquire read lock for an operation according to the lock mode.
      Parameters:
      lockMode - locking mode
    • readLockInterruptibly

      void readLockInterruptibly(RwLockMode lockMode) throws InterruptedException
      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

      void readUnlock(RwLockMode lockMode, String opName)
      Release read lock for the operation according to the lock mode.
      Parameters:
      lockMode - locking mode
      opName - operation name
    • readUnlock

      void readUnlock(RwLockMode lockMode, String opName, Supplier<String> lockReportInfoSupplier)
      Release read lock for the operation according to the lock mode.
      Parameters:
      lockMode - locking mode
      opName - operation name
      lockReportInfoSupplier - supplier used to report some information for this lock.
    • writeLock

      void writeLock(RwLockMode lockMode)
      Acquire write lock for an operation according to the lock mode.
      Parameters:
      lockMode - locking mode
    • writeUnlock

      void writeUnlock(RwLockMode lockMode, String opName)
      Release write lock for the operation according to the lock mode.
      Parameters:
      lockMode - locking mode
      opName - operation name
    • writeUnlock

      void writeUnlock(RwLockMode lockMode, String opName, boolean suppressWriteLockReport)
      Release write lock for the operation according to the lock mode.
      Parameters:
      lockMode - locking mode
      opName - operation name
      suppressWriteLockReport - When false, event of write lock being held for long time will be logged in logs and metrics.
    • writeUnlock

      void writeUnlock(RwLockMode lockMode, String opName, Supplier<String> lockReportInfoSupplier)
      Release write lock for the operation according to the lock mode.
      Parameters:
      lockMode - locking mode
      opName - operation name
      lockReportInfoSupplier - supplier used to report information for this lock.
    • writeLockInterruptibly

      void writeLockInterruptibly(RwLockMode lockMode) throws InterruptedException
      Throws:
      InterruptedException
    • hasWriteLock

      boolean hasWriteLock(RwLockMode lockMode)
      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

      boolean hasReadLock(RwLockMode lockMode)
      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

      int getReadHoldCount(RwLockMode lockMode)
      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

      int getQueueLength(RwLockMode lockMode)
      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

      long getNumOfReadLockLongHold(RwLockMode lockMode)
      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

      long getNumOfWriteLockLongHold(RwLockMode lockMode)
      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

      @VisibleForTesting void setLockForTests(ReentrantReadWriteLock lock)
    • getLockForTests

      @VisibleForTesting ReentrantReadWriteLock getLockForTests()