Package org.swisspush.gateleen.core.util
Class LockUtil
- java.lang.Object
-
- org.swisspush.gateleen.core.util.LockUtil
-
public class LockUtil extends Object
Class HttpServerRequestUtil.- Author:
- https://github.com/mcweba [Marc-Andre Weber]
-
-
Constructor Summary
Constructors Constructor Description LockUtil(GateleenExceptionFactory exceptionFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static io.vertx.core.Future<Boolean>acquireLock(Lock lockImpl, String lock, String token, long lockExpiryMs, org.slf4j.Logger log)Acquire a lock.static longcalcLockExpiry(long taskInterval)Calculate the lock expiry time.voidreleaseLock(Lock lockImpl, String lock, String token, org.slf4j.Logger log)Release a lock.
-
-
-
Constructor Detail
-
LockUtil
public LockUtil(GateleenExceptionFactory exceptionFactory)
-
-
Method Detail
-
acquireLock
public static io.vertx.core.Future<Boolean> acquireLock(Lock lockImpl, String lock, String token, long lockExpiryMs, org.slf4j.Logger log)
Acquire a lock. Resolves always toBoolean.TRUEwhen no lock implementation is provided- Parameters:
lockImpl- the lock implementationlock- the locktoken- the unique tokenlockExpiryMs- the expiry of the locklog- the logger- Returns:
- A boolean
Futurewhether the lock could has been acquired or not
-
releaseLock
public void releaseLock(Lock lockImpl, String lock, String token, org.slf4j.Logger log)
Release a lock.- Parameters:
lockImpl- the lock implementationlock- the locktoken- the unique tokenlog- the Logger
-
calcLockExpiry
public static long calcLockExpiry(long taskInterval)
Calculate the lock expiry time. This is a simple helper to work with the lock expiry time.- Parameters:
taskInterval- the interval of the task- Returns:
- the calculated lock expiry time
-
-