Class FilePadding
java.lang.Object
org.apache.zookeeper.server.persistence.FilePadding
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longcalculateFileSizeWithPadding(long position, long fileSize, long preAllocSize) Calculates a new file size with padding.static longGetter of preAllocSize has been added for testingvoidsetCurrentSize(long currentSize) static voidsetPreallocSize(long size) method to allow setting preallocate size of log file to pad the file.
-
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 tofileSize- application keeps track of the current file sizepreAllocSize- how many bytes to pad- Returns:
- the new file size. It can be the same as fileSize if no padding was done.
-