Class ProcessLockUtils
java.lang.Object
com.kingsrook.qqq.backend.core.processes.locks.ProcessLockUtils
Utility class for working with ProcessLock table - creating, checking-in,
and releasing process locks.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
input wrapper for an overload of the checkin method, to allow more flexibility w/ whether or not you want to update details invalid input: '&' expiresAtTimestamp (e.g., so a null can be passed in, to mean "set it to null" vs. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkIn
(ProcessLock processLock) Do a check-in, updating the expires-timestamp based on the lock type's default.static void
checkIn
(ProcessLock processLock, Instant expiresAtTimestamp) Do a check-in, with a specific value for the expiresAtTimestamp - which can be set to null to make it null in the lock.static void
Do a check-in, with a specific value for the expiresAtTimestamp - which can be set to null to make it null in the lock.static ProcessLock
try to create a process lock, of a given key invalid input: '&' type - but immediately fail if the lock already exists.static ProcessLock
try to create a process lock, of a given key invalid input: '&' type - and re-try if it failed.static Map
<String, ProcessLockOrException> createMany
(List<String> keys, String typeName, String details) try to create many process locks, of list of keys invalid input: '&' a type - but immediately fail (on a one-by-one basis) if the lock already exists.static Map
<String, ProcessLockOrException> createMany
(List<String> keys, String typeName, String details, Duration sleepBetweenTries, Duration maxWait) try to create many process locks, of a given list of key invalid input: '&' a type - and re-try upon failures (e.g., wait until existing lock holder releases the lock).static ProcessLock
static void
release
(ProcessLock processLock) static void
releaseById
(Integer id) static void
releaseByIds
(List<? extends Serializable> ids) static void
releaseMany
(List<ProcessLock> processLocks)
-
Constructor Details
-
ProcessLockUtils
public ProcessLockUtils()
-
-
Method Details
-
create
public static ProcessLock create(String key, String typeName, String details) throws UnableToObtainProcessLockException, QException try to create a process lock, of a given key invalid input: '&' type - but immediately fail if the lock already exists.- Parameters:
key
- along with typeName, part of Unique Key for the lock.typeName
- along with key, part of Unique Key for the lock. Must be a defined lock type, from which we derive defaultExpirationSeconds.details
- advice to show users re: who/what created the lock.- Throws:
UnableToObtainProcessLockException
QException
-
create
public static ProcessLock create(String key, String typeName, String details, Duration sleepBetweenTries, Duration maxWait) throws UnableToObtainProcessLockException, QException try to create a process lock, of a given key invalid input: '&' type - and re-try if it failed. (e.g., wait until existing lock holder releases the lock).- Parameters:
key
- along with typeName, part of Unique Key for the lock.typeName
- along with key, part of Unique Key for the lock. Must be a defined lock type, from which we derive defaultExpirationSeconds.details
- advice to show users re: who/what created the lock.sleepBetweenTries
- how long to sleep between retries.maxWait
- max amount of that will be waited between call to this method and an eventual UnableToObtainProcessLockException (plus or minus one sleepBetweenTries (actually probably just plus that).- Throws:
UnableToObtainProcessLockException
QException
-
createMany
public static Map<String,ProcessLockOrException> createMany(List<String> keys, String typeName, String details) throws QException try to create many process locks, of list of keys invalid input: '&' a type - but immediately fail (on a one-by-one basis) if the lock already exists.- Parameters:
keys
- along with typeName, part of Unique Key for the lock.typeName
- along with key, part of Unique Key for the lock. Must be a defined lock type, from which we derive defaultExpirationSeconds.details
- advice to show users re: who/what created the lock.- Throws:
QException
-
createMany
public static Map<String,ProcessLockOrException> createMany(List<String> keys, String typeName, String details, Duration sleepBetweenTries, Duration maxWait) throws QException try to create many process locks, of a given list of key invalid input: '&' a type - and re-try upon failures (e.g., wait until existing lock holder releases the lock).- Parameters:
keys
- along with typeName, part of Unique Key for the lock.typeName
- along with key, part of Unique Key for the lock. Must be a defined lock type, from which we derive defaultExpirationSeconds.details
- advice to show users re: who/what created the lock.sleepBetweenTries
- how long to sleep between retries.maxWait
- max amount of that will be waited between call to this method and an eventual UnableToObtainProcessLockException (plus or minus one sleepBetweenTries (actually probably just plus that).- Throws:
QException
-
getById
- Throws:
QException
-
checkIn
Do a check-in, with a specific value for the expiresAtTimestamp - which can be set to null to make it null in the lock. If you don't want to specify the expiresAtTimestamp, call the overload that doesn't take the timestamp - in which case it'll either stay the same as it was, or will be set based on the type's default. -
checkIn
Do a check-in, with a specific value for the expiresAtTimestamp - which can be set to null to make it null in the lock. If you don't want to specify the expiresAtTimestamp, call the overload that doesn't take the timestamp - in which case it'll either stay the same as it was, or will be set based on the type's default. -
checkIn
Do a check-in, updating the expires-timestamp based on the lock type's default. (or leaving it the same as it was (null or otherwise) if there is no default on the type). -
releaseById
-
releaseByIds
-
release
-
releaseMany
-