Class FilePadding

java.lang.Object
org.apache.zookeeper.server.persistence.FilePadding

public class FilePadding extends Object
  • Constructor Details

    • FilePadding

      public FilePadding()
  • Method Details

    • getPreAllocSize

      public static long getPreAllocSize()
      Getter of preAllocSize has been added for testing
    • setPreallocSize

      public static void setPreallocSize(long size)
      method to allow setting preallocate size of log file to pad the file.
      Parameters:
      size - the size to set to in bytes
    • setCurrentSize

      public void setCurrentSize(long currentSize)
    • calculateFileSizeWithPadding

      public static long calculateFileSizeWithPadding(long position, long fileSize, long preAllocSize)
      Calculates a new file size with padding. We only return a new size if the current file position is sufficiently close (less than 4K) to end of file and preAllocSize is > 0.
      Parameters:
      position - the point in the file we have written to
      fileSize - application keeps track of the current file size
      preAllocSize - how many bytes to pad
      Returns:
      the new file size. It can be the same as fileSize if no padding was done.