Class WindowFile

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

public final class WindowFile extends Object
The window file of a StaticSlot (05-machine-lease.md ยง4.4): one ceiling, written to a temporary file, fsynced, then moved over the old file atomically, so a crash leaves either the old or the new ceiling, never a torn one.
  • Constructor Details

    • WindowFile

      public WindowFile(Path path)
      A window file.
      Parameters:
      path - the file
  • Method Details

    • path

      public Path path()
    • read

      public OptionalLong read()
      Reads the persisted ceiling.
      Returns:
      the ceiling in milliseconds, or empty if the file does not exist
      Throws:
      CosIdException - if the file is not a window file: refusing beats guessing a floor
      UncheckedIOException - if the file cannot be read
    • write

      public void write(long ceiling)
      Persists ceiling durably: when this returns, a crash cannot lose it.
      Parameters:
      ceiling - the ceiling in milliseconds
      Throws:
      UncheckedIOException - if the file cannot be written