Interface StateChangelogWriter<Handle extends ChangelogStateHandle>

All Superinterfaces:
AutoCloseable

@Internal public interface StateChangelogWriter<Handle extends ChangelogStateHandle> extends AutoCloseable
Allows to write data to the log. Scoped to a single writer (e.g. state backend).
  • Method Details

    • initialSequenceNumber

      SequenceNumber initialSequenceNumber()
      Get the initial SequenceNumber that is used for the first element.
    • nextSequenceNumber

      SequenceNumber nextSequenceNumber()
      Get SequenceNumber to be used for the next element added by append.
    • appendMeta

      void appendMeta(byte[] value) throws IOException
      Appends the provided **metadata** to this log. No persistency guarantees.
      Throws:
      IOException
    • append

      void append(int keyGroup, byte[] value) throws IOException
      Appends the provided data to this log. No persistency guarantees.
      Throws:
      IOException
    • persist

      CompletableFuture<SnapshotResult<Handle>> persist(SequenceNumber from, long checkpointId) throws IOException
      Durably persist previously appended data starting from the provided SequenceNumber and up to the latest change added. After this call, one of confirm, reset, or truncate eventually must be called for the corresponding change set. with reset/truncate/confirm methods?
      Parameters:
      from - inclusive
      checkpointId - to persist
      Throws:
      IOException
    • truncate

      void truncate(SequenceNumber to)
      Truncate this state changelog to free up the resources and collect any garbage. That means:
      • Discard the written state changes - in the provided range [from; to)
      • Truncate the in-memory view of this changelog - in the range [0; to)
      Called upon state materialization. Any ongoing persist calls will not be affected.

      WARNING: the range [from; to) must not include any range that is included into any checkpoint that is not subsumed or aborted.

      Parameters:
      to - exclusive
    • confirm

      void confirm(SequenceNumber from, SequenceNumber to, long checkpointId)
      Mark the given state changes as confirmed by the JM.
      Parameters:
      from - inclusive
      to - exclusive
      checkpointId - to confirm
    • reset

      void reset(SequenceNumber from, SequenceNumber to, long checkpointId)
      Reset the state the given state changes. Called upon abortion so that if requested later then these changes will be re-uploaded.
    • truncateAndClose

      void truncateAndClose(SequenceNumber from)
      Truncate the tail of log and close it. No new appends will be possible. Any appended but not persisted records will be lost.
      Parameters:
      from - SequenceNumber from which to truncate the changelog, inclusive
    • close

      void close()
      Close this log. No new appends will be possible. Any appended but not persisted records will be lost.
      Specified by:
      close in interface AutoCloseable