Package io.ocfl.core.lock
Class ObjectLockBuilder
java.lang.Object
io.ocfl.core.lock.ObjectLockBuilder
Constructs new
ObjectLock
instances-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Constructs a newObjectLock
.dataSource
(DataSource dataSource) Sets the DataSource to use for DB based locking.maxLockDuration
(Duration maxLockDuration) Sets the maximum amount of time a lock may be held for before it's able to be acquired by another process.Sets the name of the table to use for object locking.Used to override the amount of time the client will wait to obtain an object lock.
-
Constructor Details
-
ObjectLockBuilder
public ObjectLockBuilder()
-
-
Method Details
-
waitTime
Used to override the amount of time the client will wait to obtain an object lock. Default: 10 seconds.This only applies to in-memory locks
- Parameters:
waitTime
- wait timetimeUnit
- unit of time- Returns:
- builder
-
dataSource
Sets the DataSource to use for DB based locking. This MUST be set in order to create a DB lock.- Parameters:
dataSource
- the DataSource to use- Returns:
- builder
-
tableName
Sets the name of the table to use for object locking. Default: ocfl_object_lock- Parameters:
tableName
- the table name to use- Returns:
- builder
-
maxLockDuration
Sets the maximum amount of time a lock may be held for before it's able to be acquired by another process. Default: 1 hourThis only applies for database locks, and is used to avoid permanently locking an object if the process that acquired the lock dies without releasing the lock. This duration should be fairly generous to allow sufficient time for slow S3 writes.
- Parameters:
maxLockDuration
- the maximum amount of time a lock may be held for- Returns:
- builder
-
build
Constructs a newObjectLock
. If a DataSource was set, then a DB lock is created; otherwise, an in-memory lock is used.- Returns:
- object lock
-