Module net.javacrumbs.shedlock.core
Package net.javacrumbs.shedlock.support
Class KeepAliveLockProvider
java.lang.Object
net.javacrumbs.shedlock.support.KeepAliveLockProvider
- All Implemented Interfaces:
LockProvider
LockProvider that keeps the lock `alive`. In the middle of lockAtMostFor
period tries to extend the lock for lockAtMostFor period. For example, if the
lockAtMostFor is 10 minutes the lock is extended every 5 minutes for 10
minutes until the lock is released. If the process dies, the lock is
automatically released after lockAtMostFor period as usual.
Does not support lockAtMostFor shorter than 30s. The reason is that with short (subsecond) lockAtMostFor time the time when we attmpt to extend the lock is too close to the expiration time and the lock can expire before we are able to extend it.
Wraps ExtensibleLockProvider that implements the actual locking.
-
Constructor Summary
ConstructorsConstructorDescriptionKeepAliveLockProvider(ExtensibleLockProvider wrapped, ScheduledExecutorService executorService) -
Method Summary
-
Constructor Details
-
KeepAliveLockProvider
public KeepAliveLockProvider(ExtensibleLockProvider wrapped, ScheduledExecutorService executorService)
-
-
Method Details
-
lock
- Specified by:
lockin interfaceLockProvider- Returns:
- If empty optional has been returned, lock could not be acquired. The lock has to be released by the callee.
-