Interface SessionLockListener
- All Superinterfaces:
Serializable
All Vaadin server-side work for a single session is serialized behind one
lock, so the time a thread blocks acquiring it and the time it holds it are
key performance signals. Callbacks are delivered for the outermost
acquisition only (reentrant re-locks are not reported), and the three
callbacks for a single hold are delivered on the same thread in the order
lockRequested(com.vaadin.flow.server.SessionLockEvent), lockAcquired(com.vaadin.flow.server.SessionLockEvent), lockReleased(com.vaadin.flow.server.SessionLockEvent), so a
listener can record the start time in a ThreadLocal on
lockRequested, derive the wait time on lockAcquired, and the
hold time on lockReleased.
When several listeners are registered, lockRequested(com.vaadin.flow.server.SessionLockEvent) and
lockAcquired(com.vaadin.flow.server.SessionLockEvent) are delivered in registration order while
lockReleased(com.vaadin.flow.server.SessionLockEvent) is delivered in reverse registration order, so the
callbacks nest like try/finally blocks: a listener registered
later sees its lockReleased run before that of a listener registered
earlier.
Implementations must be fast and non-blocking: callbacks run on the request/access thread directly around the lock operation. Exceptions thrown from a callback are logged and suppressed so they cannot disrupt session locking.
Register via
VaadinService.addSessionLockListener(SessionLockListener), typically
from a VaadinServiceInitListener. Listeners registered after a
session's lock has already been created are still honoured.
- Since:
- 25.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidlockAcquired(SessionLockEvent event) Invoked on the locking thread immediately after it has acquired the session lock for an outermost acquisition.default voidlockReleased(SessionLockEvent event) Invoked on the locking thread immediately after the outermost lock hold has been released (the lock's hold count reached zero).default voidlockRequested(SessionLockEvent event) Invoked on the locking thread immediately before it attempts to acquire the session lock for an outermost (non-reentrant) acquisition.
-
Method Details
-
lockRequested
Invoked on the locking thread immediately before it attempts to acquire the session lock for an outermost (non-reentrant) acquisition. The thread may block between this callback andlockAcquired(com.vaadin.flow.server.SessionLockEvent); the elapsed time is the lock wait time. For a non-blocking acquisition (tryLock) this is delivered together withlockAcquired(com.vaadin.flow.server.SessionLockEvent)only when the lock was actually taken, so the reported wait time is effectively zero.- Parameters:
event- the session lock event
-
lockAcquired
Invoked on the locking thread immediately after it has acquired the session lock for an outermost acquisition.- Parameters:
event- the session lock event
-
lockReleased
Invoked on the locking thread immediately after the outermost lock hold has been released (the lock's hold count reached zero). The time sincelockAcquired(com.vaadin.flow.server.SessionLockEvent)is the lock hold time.- Parameters:
event- the session lock event
-