Grants short-lived, key-based locks so callers can serialise access to an entity or other resource, either within this server (local) or across the cluster (global). A caller builds a LockRequest via newLockRequest(), then locks it directly or runs a Runnable/Callable while holding it. Reached from JS as the registered entityLockManager service, though AppTransactionManager is the preferred entry point for app code.

Group: Managers


Properties

PropertyReturnsDescription
lockStatsMapReports lock activity for both the local and global lock services, for the maintenance page in the root account. Each entry gives the lock service's implementation type and its internal statistics.

Methods

getLockStats()

Returns: Map

Reports lock activity for both the local and global lock services, for the maintenance page in the root account. Each entry gives the lock service's implementation type and its internal statistics.

findLock(boolean isLocal, String key)

Returns: LockRequest

Looks up a currently held lock by its key.

ParameterDescription
isLocaltrue to search the local (in-process) lock service, false for the global (cluster wide) service
keythe lock key to look up

currentLocks(int from, int maxSize, boolean isLocal)

Returns: List<LockRequest>

Returns a page of currently active locks.

ParameterDescription
fromthe zero based index of the first lock to return
maxSizethe maximum number of locks to return
isLocaltrue to page the local (in-process) lock service, false for the global (cluster wide) service

newLockRequest(Object entity)

Returns: LockRequestBuilder

Starts building a lock request for the given target, deriving the lock key from it. The target must be a Relational database entity, or a String, Long or Integer to use directly as the key.

ParameterDescription
entitythe object to derive the lock key from

lockAndRun(LockRequestBuilder lrb, Runnable r)

Returns: void

Acquires a lock built from the given request, runs the given task, then releases the lock, even if the task throws.

ParameterDescription
lrbthe lock request to build and acquire, which also selects the local or global lock service
rthe task to run while the lock is held

lockAndProduce(LockRequestBuilder lrb, Callable<T> c)

Returns: T

Acquires a lock built from the given request, runs the given task and returns its result, then releases the lock, even if the task throws.

ParameterDescription
lrbthe lock request to build and acquire, which also selects the local or global lock service
cthe task to run while the lock is held

getKey(Object targetObject)

Returns: String

Derives the lock key that would be used for the given target: a Relational entity's row id, or a String, Long or Integer used directly.

ParameterDescription
targetObjectthe object to derive the lock key from
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.