Class VeniceLock


  • public class VeniceLock
    extends java.lang.Object
    Venice wrapper around a Lock object to record metrics and emit logs when lock acquisition is taking too long.
    • Constructor Summary

      Constructors 
      Constructor Description
      VeniceLock​(java.util.concurrent.locks.Lock lock, java.lang.String lockDescription, io.tehuti.metrics.MetricsRepository metricsRepository)  
      VeniceLock​(java.util.concurrent.locks.Lock lock, java.lang.String lockDescription, io.tehuti.metrics.MetricsRepository metricsRepository, long reportingThresholdMs)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void lock()
      Attempt to acquire the lock.
      void unlock()
      Attempt to unlock.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VeniceLock

        public VeniceLock​(java.util.concurrent.locks.Lock lock,
                          java.lang.String lockDescription,
                          io.tehuti.metrics.MetricsRepository metricsRepository,
                          long reportingThresholdMs)
        Parameters:
        lock - underlying Lock.
        lockDescription - that describes the lock to give context and information in logs and metrics.
        metricsRepository - to emit related metrics to.
        reportingThresholdMs - to emit metrics and logs when a thread is taking a long time to acquire the lock. The same threshold is also used to emit metrics and logs upon releasing a lock that was been held for extended period of time.
      • VeniceLock

        public VeniceLock​(java.util.concurrent.locks.Lock lock,
                          java.lang.String lockDescription,
                          io.tehuti.metrics.MetricsRepository metricsRepository)
    • Method Detail

      • lock

        public void lock()
        Attempt to acquire the lock. Metric is reported every time we failed to acquire the lock within the given reportingThresholdMs. Note that the reportingThresholdMs is only used for reporting purpose. That is, no other actions upon timing out other than keep trying to acquire the lock.
      • unlock

        public void unlock()
        Attempt to unlock. Might throw IllegalMonitorStateException if the current thread does not hold this lock.