Abstract lock that implements the default lock acquisition routine.
Implements: ILock, IReconfigurable
Description
The Lock class represents an abstract lock that implements the defaul lock acquisition routine.
Configuration parameters
options:
- retry_timeout: timeout in milliseconds to retry lock acquisition. (Default: 100)
Instance methods
acquireLock
Makes multiple attempts to acquire a lock by its key within a given time interval.
publicvoid acquireLock(IContext context, String key, int ttl, long timeout) throws InterruptedException, ApplicationException
- context: IContext - (optional) a context to trace execution through call chain.
- key: String - a unique lock key to acquire.
- ttl: int - a lock timeout (time to live) in milliseconds.
- timeout: long - a lock acquisition timeout.
configure
Configures component by passing configuration parameters.
publicvoid configure(ConfigParams config)
- config: ConfigParams - configuration parameters to be set.
Abstract methods
releaseLock
Releases a prevously acquired lock by its key.
public abstractvoid releaseLock(IContext context, String key)
- context: IContext - (optional) a context to trace execution through call chain.
- key: string - a unique lock key to release.
tryAcquireLock
Makes a single attempt to acquire a lock by its key. It returns immediately a positive or negative result.
public abstractboolean tryAcquireLock(IContext context, String key, int ttl)
- context: IContext - (optional) a context to trace execution through call chain.
- key: String - a unique lock key to acquire.
- ttl: int - a lock timeout (time to live) in milliseconds.
- returns: boolean - lock result