Class PersistentLongFile

java.lang.Object
org.apache.hadoop.hdfs.util.PersistentLongFile

@Private public class PersistentLongFile extends Object
Class that represents a file on disk which persistently stores a single long value. The file is updated atomically and durably (i.e fsynced).
  • Constructor Details

    • PersistentLongFile

      public PersistentLongFile(File file, long defaultVal)
  • Method Details

    • get

      public long get() throws IOException
      Throws:
      IOException
    • set

      public void set(long newVal) throws IOException
      Throws:
      IOException
    • writeFile

      public static void writeFile(File file, long val) throws IOException
      Atomically write the given value to the given file, including fsyncing.
      Parameters:
      file - destination file
      val - value to write
      Throws:
      IOException - if the file cannot be written
    • readFile

      public static long readFile(File file, long defaultVal) throws IOException
      Throws:
      IOException