Class FilePositionStore

java.lang.Object
com.arpnetworking.metrics.common.tailer.FilePositionStore
All Implemented Interfaces:
PositionStore, Closeable, AutoCloseable

public final class FilePositionStore extends Object implements PositionStore
Implementation of PositionStore which stores the read position in a file on local disk. This class is thread-safe per file identifier.
Author:
Ville Koskela (ville dot koskela at inscopemetrics dot io)
  • Method Details

    • getPosition

      public Optional<Long> getPosition(String identifier)
      Description copied from interface: PositionStore
      Get the read location in the file identified by a hash.
      Specified by:
      getPosition in interface PositionStore
      Parameters:
      identifier - unique identifier for the file.
      Returns:
      Optional.absent if the file was not found, otherwise a byte offset
    • setPosition

      public void setPosition(String identifier, long position)
      Description copied from interface: PositionStore
      Update the read offset from the beginning of the file for the specified file identifier.
      Specified by:
      setPosition in interface PositionStore
      Parameters:
      identifier - unique identifier for the file.
      position - the new read offset from the beginning of the file in bytes.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • toLogValue

      public Object toLogValue()
      Generate a Steno log compatible representation.
      Returns:
      Steno log compatible representation.
    • toString

      public String toString()
      Overrides:
      toString in class Object