Interface MachineStateStorage

All Known Implementing Classes:
InMemoryMachineStateStorage, LocalMachineStateStorage

@ThreadSafe public interface MachineStateStorage
Machine state storage for persisting machine state across restarts.

Provides an interface for storing and retrieving machine state information, which is essential for maintaining machine ID allocations in distributed ID generation systems.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final MachineStateStorage
    In-memory machine state storage instance.
    static final MachineStateStorage
    Local machine state storage instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(String namespace)
    Clears all machine states for a given namespace.
    boolean
    exists(String namespace, InstanceId instanceId)
    Checks if a machine state exists for a given namespace and instance.
    @NonNull MachineState
    get(String namespace, InstanceId instanceId)
    Gets the machine state for a given namespace and instance.
    void
    remove(String namespace, InstanceId instanceId)
    Removes the machine state for a given namespace and instance.
    void
    set(String namespace, int machineId, InstanceId instanceId)
    Sets the machine state for a given namespace and instance.
    int
    size(String namespace)
    Gets the number of machine states in a namespace.
  • Field Details

  • Method Details

    • get

      @NonNull MachineState get(String namespace, InstanceId instanceId)
      Gets the machine state for a given namespace and instance.
      Parameters:
      namespace - the namespace
      instanceId - the instance ID
      Returns:
      the machine state, or NOT_FOUND if not found
    • set

      void set(String namespace, int machineId, InstanceId instanceId)
      Sets the machine state for a given namespace and instance.
      Parameters:
      namespace - the namespace
      machineId - the machine ID
      instanceId - the instance ID
    • remove

      void remove(String namespace, InstanceId instanceId)
      Removes the machine state for a given namespace and instance.
      Parameters:
      namespace - the namespace
      instanceId - the instance ID
    • clear

      void clear(String namespace)
      Clears all machine states for a given namespace.
      Parameters:
      namespace - the namespace
    • size

      int size(String namespace)
      Gets the number of machine states in a namespace.
      Parameters:
      namespace - the namespace
      Returns:
      the number of machine states
    • exists

      boolean exists(String namespace, InstanceId instanceId)
      Checks if a machine state exists for a given namespace and instance.
      Parameters:
      namespace - the namespace
      instanceId - the instance ID
      Returns:
      true if the state exists