Package com.linkedin.venice.utils
Class VeniceLock
java.lang.Object
com.linkedin.venice.utils.VeniceLock
Venice wrapper around a
Lock
object to record metrics and emit logs when lock acquisition is taking too long.-
Constructor Summary
ConstructorDescriptionVeniceLock
(Lock lock, String lockDescription, io.tehuti.metrics.MetricsRepository metricsRepository) VeniceLock
(Lock lock, String lockDescription, io.tehuti.metrics.MetricsRepository metricsRepository, long reportingThresholdMs) -
Method Summary
-
Constructor Details
-
VeniceLock
public VeniceLock(Lock lock, 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
-
-
Method Details
-
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.
-