java.lang.Object
de.aristaflow.adept2.base.registry.dbconfiguration.TableStatus

public final class TableStatus extends Object
The cached existence of the table for a runtime configuration, shared between a TableManager and the corresponding DatabaseConfiguration. null means the existence is unknown, so the next access will check the meta data.
The TableManager creates and drops the table and checks the meta data under its own lock, so what it learns is the current status by definition and it sets the status unconditionally. The DatabaseConfiguration only observes: its changes carry the nano timestamp of the TableStatus.Snapshot the observation started from and will only be applied if the stamp has not advanced in the meantime. Otherwise the fresher status stands. This way an observation that started before a change of the table by the manager can never overwrite the status set for that change.
The methods of this class must not perform any I/O, so its lock is only ever held briefly.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A snapshot of the table status.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new table status with the designated initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    set(boolean exists)
    Sets the designated status unconditionally.
    set(Boolean exists, long observedAt)
    Sets the designated status (null for unknown) derived from an observation that started at the designated stamp.
    Gets the current status and the stamp of its last change or unconditional set atomically.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TableStatus

      public TableStatus(Boolean exists)
      Creates a new table status with the designated initial value.
      Parameters:
      exists - Whether the table exists; null if unknown.
  • Method Details

    • snapshot

      public TableStatus.Snapshot snapshot()
      Gets the current status and the stamp of its last change or unconditional set atomically.
      Returns:
      A snapshot of the current status. This will never be null.
    • set

      public void set(boolean exists)
      Sets the designated status unconditionally. This is for the TableManager, which creates and drops the table itself and checks the meta data under its lock, so what it sets is the current status by definition. The stamp always advances, so observations started before will be rejected by set(Boolean, long).
      Parameters:
      exists - Whether the table exists.
    • set

      public TableStatus.Snapshot set(Boolean exists, long observedAt)
      Sets the designated status (null for unknown) derived from an observation that started at the designated stamp. The status will only be applied if the stamp has not advanced since then; setting the same value again does not advance the stamp.
      Parameters:
      exists - Whether the table exists; null if unknown.
      observedAt - The stamp of the snapshot the observation started from.
      Returns:
      The resulting snapshot. Its status is the designated one if this has been applied or has been set before; otherwise it is the fresher status set in the meantime, which stands. This will never be null.