Class DynamoDBLockProvider
- java.lang.Object
-
- net.javacrumbs.shedlock.provider.dynamodb.DynamoDBLockProvider
-
- All Implemented Interfaces:
LockProvider
public class DynamoDBLockProvider extends Object implements LockProvider
Distributed lock using DynamoDB. Depends onaws-java-sdk-dynamodb.It uses a table with the following structure:
{ "_id" : "lock name", "lockUntil" : ISODate("2017-01-07T16:52:04.071Z"), "lockedAt" : ISODate("2017-01-07T16:52:03.932Z"), "lockedBy" : "host name" }lockedAtandlockedByare just for troubleshooting and are not read by the code.- Attempts to insert a new lock record.
-
We will try to update lock record using
filter _id == :name AND lock_until <= :now. - If the update succeeded, we have the lock. If the update failed (condition check exception) somebody else holds the lock.
-
When unlocking,
lock_untilis set to now or lockAtLeastUntil whichever is later.
-
-
Constructor Summary
Constructors Constructor Description DynamoDBLockProvider(@NotNull com.amazonaws.services.dynamodbv2.document.Table table)Uses DynamoDB to coordinate locks
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Optional<SimpleLock>lock(@NotNull LockConfiguration lockConfiguration)
-
-
-
Method Detail
-
lock
@NotNull public @NotNull Optional<SimpleLock> lock(@NotNull @NotNull LockConfiguration lockConfiguration)
- Specified by:
lockin interfaceLockProvider
-
-