Class RuntimeParts

java.lang.Object
me.ahoo.cosid.internal.RuntimeParts

public final class RuntimeParts extends Object
What a runtime is made of, assembled in order (stores, the machine slot, generators) and closed in reverse (07-runtime-and-spring.md §1, 05-machine-lease.md §4.3). A failed start closes what it created.
  • Method Details

    • ownExecutor

      public static ExecutorService ownExecutor(String namespace)
      The runtime's own executor: a virtual thread per task, named after the namespace.
      Parameters:
      namespace - the namespace
      Returns:
      the executor
    • assemble

      public static RuntimeParts assemble(RuntimeSpec spec, RuntimeOptions options, Function<String,ExecutorService> ownExecutors)
      Checks the spec, then opens the stores, acquires the slot and creates the generators; on failure closes what was created and rethrows.
      Parameters:
      spec - the spec
      options - the options
      ownExecutors - creates the runtime's own executor when the options have none
      Returns:
      the parts
      Throws:
      CosIdException - if the spec is invalid or a step fails
    • namespace

      public String namespace()
    • generators

      public Map<String,GeneratorEntry> generators()
      The generators by name, in name order.
      Returns:
      the generators
    • lease

      public Optional<SlotLease> lease()
      The slot lease of the default machine, when it is leased.
      Returns:
      the lease, empty with a static slot, without a slot, or once closed
    • lease

      public Optional<SlotLease> lease(String machine)
      The slot lease of a started machine, when it is leased.
      Parameters:
      machine - the machine name, "default" for the default one
      Returns:
      the lease, empty with a static slot, for a machine that did not start, or once closed
    • machines

      public Map<String,String> machines()
      The started machines by name, in start order, with their namespaces.
      Returns:
      the namespaces by machine name
    • close

      public void close()
      Closes in reverse dependency order (05-machine-lease.md §4.3): every time-based generator, then the other generators, then the slot released with the exact largest timestamp the generators issued, then the stores in reverse order, then the own executor. Every step runs even if an earlier one fails. Closing again does nothing.
      Throws:
      CosIdException - if a step failed, with each failure suppressed