Class MachineSpec.Leased

java.lang.Object
me.ahoo.cosid.runtime.MachineSpec.Leased
All Implemented Interfaces:
MachineSpec
Enclosing interface:
MachineSpec

public static final class MachineSpec.Leased extends Object implements MachineSpec
A slot leased from a store.
  • Method Details

    • builder

      public static MachineSpec.Leased.Builder builder(String store)
      A builder of a leased slot.
      Parameters:
      store - the store name
      Returns:
      the builder
    • store

      public String store()
      The store name.
      Returns:
      the store name
    • bits

      public int bits()
      The slot bits: the slots are [0, 2^bits).
      Specified by:
      bits in interface MachineSpec
      Returns:
      the slot bits; default 10
    • ttl

      public Duration ttl()
      The lease time to live.
      Returns:
      the ttl; default 30s
    • tolerance

      public Duration tolerance()
      How far beyond the expiry the ceiling lies (D20).
      Returns:
      the tolerance; default 1s
    • acquireTimeout

      public Duration acquireTimeout()
      How long CosIdRuntime.start waits for a slot while every slot is held (D42): it retries as leases expire, then fails; Duration.ZERO tries once. Align it with the startup probe of a rolling update.
      Returns:
      the acquire timeout, not negative; default the ttl()
    • slotOffset

      public int slotOffset()
      Added to the slot to give the node of the ids (api-freeze.md §2.1.1): the nodes of this machine are [slotOffset, slotOffset + 2^bits), apart from the 4.x machine ids below it during a rolling migration. The store keeps the slots [0, 2^bits) and records the offset; every client of the namespace must use the same one, and once used it never changes.
      Returns:
      the slot offset, not negative; default 0
    • preferredSlot

      public OptionalInt preferredSlot()
      The slot to try first, such as a StatefulSet ordinal.
      Returns:
      the preferred slot; default none
    • ownerKey

      public Optional<String> ownerKey()
      The owner key.
      Returns:
      the owner key; derived as in 07 §1.1 when empty (the default)
    • namespace

      public Optional<String> namespace()
      Description copied from interface: MachineSpec
      The namespace of the slot leases (D37): a machine shared by several services, such as the slot of a cosid80 generator unique across them, names its own; every machine of a runtime has another namespace.
      Specified by:
      namespace in interface MachineSpec
      Returns:
      the namespace; empty for the RuntimeSpec.namespace()
    • withNamespace

      public MachineSpec.Leased withNamespace(String namespace)
      This machine in another namespace.
      Parameters:
      namespace - the namespace of the slot leases
      Returns:
      the machine
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object