java.util.concurrent.locks.LockInstrumentedReadLock, InstrumentedWriteLock@Private
@Unstable
public class InstrumentedLock
extends java.lang.Object
implements java.util.concurrent.locks.Lock
| Modifier and Type | Class | Description |
|---|---|---|
protected static class |
InstrumentedLock.SuppressedSnapshot |
Immutable class to capture a snapshot of suppressed log message stats.
|
| Constructor | Description |
|---|---|
InstrumentedLock(java.lang.String name,
org.slf4j.Logger logger,
long minLoggingGapMs,
long lockWarningThresholdMs) |
Create a instrumented lock instance which logs a warning message
when lock held time is above given threshold.
|
InstrumentedLock(java.lang.String name,
org.slf4j.Logger logger,
java.util.concurrent.locks.Lock lock,
long minLoggingGapMs,
long lockWarningThresholdMs) |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
check(long acquireTime,
long releaseTime,
boolean checkLockHeld) |
Log a warning if the lock was held for too long.
|
protected java.util.concurrent.locks.Lock |
getLock() |
|
protected Timer |
getTimer() |
|
void |
lock() |
|
void |
lockInterruptibly() |
|
java.util.concurrent.locks.Condition |
newCondition() |
|
protected void |
startLockTiming() |
Starts timing for the instrumented lock.
|
boolean |
tryLock() |
|
boolean |
tryLock(long time,
java.util.concurrent.TimeUnit unit) |
|
void |
unlock() |
public InstrumentedLock(java.lang.String name,
org.slf4j.Logger logger,
long minLoggingGapMs,
long lockWarningThresholdMs)
name - the identifier of the lock objectlogger - this class does not have its own logger, will log to the
given logger insteadminLoggingGapMs - the minimum time gap between two log messages,
this is to avoid spamming to many logslockWarningThresholdMs - the time threshold to view lock held
time as being "too long"public InstrumentedLock(java.lang.String name,
org.slf4j.Logger logger,
java.util.concurrent.locks.Lock lock,
long minLoggingGapMs,
long lockWarningThresholdMs)
public void lock()
lock in interface java.util.concurrent.locks.Lockpublic void lockInterruptibly()
throws java.lang.InterruptedException
lockInterruptibly in interface java.util.concurrent.locks.Lockjava.lang.InterruptedExceptionpublic boolean tryLock()
tryLock in interface java.util.concurrent.locks.Lockpublic boolean tryLock(long time,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
tryLock in interface java.util.concurrent.locks.Lockjava.lang.InterruptedExceptionpublic void unlock()
unlock in interface java.util.concurrent.locks.Lockpublic java.util.concurrent.locks.Condition newCondition()
newCondition in interface java.util.concurrent.locks.Lockprotected void startLockTiming()
protected void check(long acquireTime,
long releaseTime,
boolean checkLockHeld)
acquireTime - - timestamp just after acquiring the lock.releaseTime - - timestamp just before releasing the lock.checkLockHeld - checkLockHeld.protected java.util.concurrent.locks.Lock getLock()
protected Timer getTimer()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.