Class SlotLease.Builder

java.lang.Object
me.ahoo.cosid.lease.SlotLease.Builder
Enclosing class:
SlotLease

public static final class SlotLease.Builder extends Object
Builds a SlotLease; build() checks the fields.
  • Method Details

    • namespace

      public SlotLease.Builder namespace(String namespace)
      Sets the namespace; required.
      Parameters:
      namespace - the namespace
      Returns:
      this builder
    • slot

      public SlotLease.Builder slot(int slot)
      Sets the slot.
      Parameters:
      slot - the slot, not negative
      Returns:
      this builder
    • owner

      public SlotLease.Builder owner(Owner owner)
      Sets the holder; required.
      Parameters:
      owner - the owner
      Returns:
      this builder
    • fence

      public SlotLease.Builder fence(long fence)
      Sets the fence.
      Parameters:
      fence - the fence
      Returns:
      this builder
    • expiresAt

      public SlotLease.Builder expiresAt(long expiresAt)
      Sets when others may take the slot over.
      Parameters:
      expiresAt - the expiry
      Returns:
      this builder
    • floor

      public SlotLease.Builder floor(long floor)
      Sets the floor: the holder issues timestamps strictly above it.
      Parameters:
      floor - the floor
      Returns:
      this builder
    • ceiling

      public SlotLease.Builder ceiling(long ceiling)
      Sets the ceiling: the holder issues timestamps up to it, inclusive.
      Parameters:
      ceiling - the ceiling, not below the floor
      Returns:
      this builder
    • storeNow

      public SlotLease.Builder storeNow(long storeNow)
      Sets the store clock of the write that produced the lease.
      Parameters:
      storeNow - the store time
      Returns:
      this builder
    • build

      public SlotLease build()
      Builds the lease.
      Returns:
      the lease
      Throws:
      NullPointerException - if the namespace or the owner is not set
      IllegalArgumentException - if the slot is negative or the ceiling is below the floor