Package edu.wisc.library.ocfl.core.lock
Class ObjectLockBuilder
- java.lang.Object
-
- edu.wisc.library.ocfl.core.lock.ObjectLockBuilder
-
public class ObjectLockBuilder extends Object
Constructs newObjectLockinstances
-
-
Constructor Summary
Constructors Constructor Description ObjectLockBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectLockbuild()Constructs a newObjectLock.ObjectLockBuilderdataSource(DataSource dataSource)Sets the DataSource to use for DB based locking.ObjectLockBuildermaxLockDuration(Duration maxLockDuration)Sets the maximum amount of time a lock may be held for before it's able to be acquired by another process.ObjectLockBuildertableName(String tableName)Sets the name of the table to use for object locking.ObjectLockBuilderwaitTime(long waitTime, TimeUnit timeUnit)Used to override the amount of time the client will wait to obtain an object lock.
-
-
-
Method Detail
-
waitTime
public ObjectLockBuilder waitTime(long waitTime, TimeUnit timeUnit)
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
public ObjectLockBuilder dataSource(DataSource 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
public ObjectLockBuilder tableName(String 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
public ObjectLockBuilder 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. 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
public ObjectLock 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
-
-