Package com.linkedin.venice.utils
Class VeniceLock
- java.lang.Object
-
- com.linkedin.venice.utils.VeniceLock
-
public class VeniceLock extends java.lang.Object
Venice wrapper around aLock
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.
-
-
-
Constructor Detail
-
VeniceLock
public VeniceLock(java.util.concurrent.locks.Lock lock, java.lang.String lockDescription, io.tehuti.metrics.MetricsRepository metricsRepository, long reportingThresholdMs)
- Parameters:
lock
- underlyingLock
.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.
-
-