Class ObjectLockBuilder

java.lang.Object
io.ocfl.core.lock.ObjectLockBuilder

public class ObjectLockBuilder extends Object
Constructs new ObjectLock instances
  • Constructor Details

    • ObjectLockBuilder

      public ObjectLockBuilder()
  • Method Details

    • 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 time
      timeUnit - 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 hour

      This 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 new ObjectLock. If a DataSource was set, then a DB lock is created; otherwise, an in-memory lock is used.
      Returns:
      object lock