FilePadding (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.server.persistence

## Class FilePadding

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

-     public class FilePadding
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FilePadding()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static long` | `calculateFileSizeWithPadding(long position, long fileSize, long preAllocSize)` Calculates a new file size with padding.
    `static long` | `getPreAllocSize()` Getter of preAllocSize has been added for testing
    `void` | `setCurrentSize(long currentSize)`
    `static void` | `setPreallocSize(long size)` method to allow setting preallocate size of log file to pad the file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FilePadding

          public FilePadding()

  - ### Method Detail

    - #### 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.

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.