Package org.apache.bookkeeper.util
Class DiskChecker
java.lang.Object
org.apache.bookkeeper.util.DiskChecker
Class that provides utility functions for checking disk problems.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA disk error exception.static classA general marker for disk-related exceptions.static classAn out-of-space disk exception.static classA disk warn threshold exception. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatCreate the directory if it doesn't exist.(package private) floatcheckDiskFull(File dir) Checks the disk space available.floatfloatlonggetTotalDiskSpace(List<File> dirs) Calculate the total amount of disk space in all of the ledger directories put together.floatgetTotalDiskUsage(List<File> dirs) calculates and returns the disk usage factor in the provided list of dirs.longgetTotalFreeSpace(List<File> dirs) Calculate the total amount of free space available in all of the ledger directories put together.(package private) voidsetDiskSpaceThreshold(float diskSpaceThreshold, float diskUsageWarnThreshold) Set the disk space threshold.
-
Constructor Details
-
DiskChecker
public DiskChecker(float threshold, float warnThreshold)
-
-
Method Details
-
checkDiskFull
float checkDiskFull(File dir) throws DiskChecker.DiskOutOfSpaceException, DiskChecker.DiskWarnThresholdException Checks the disk space available.- Parameters:
dir- Directory to check for the disk space- Throws:
DiskChecker.DiskOutOfSpaceException- ThrowsDiskChecker.DiskOutOfSpaceExceptionif available space is less than threshold.DiskChecker.DiskWarnThresholdException
-
getTotalFreeSpace
Calculate the total amount of free space available in all of the ledger directories put together.- Returns:
- freeDiskSpace in bytes
- Throws:
IOException
-
getTotalDiskSpace
Calculate the total amount of disk space in all of the ledger directories put together.- Returns:
- totalDiskSpace in bytes
- Throws:
IOException
-
getTotalDiskUsage
calculates and returns the disk usage factor in the provided list of dirs.- Parameters:
dirs- list of directories- Returns:
- disk usage factor in the provided list of dirs
- Throws:
IOException
-
checkDir
public float checkDir(File dir) throws DiskChecker.DiskErrorException, DiskChecker.DiskOutOfSpaceException, DiskChecker.DiskWarnThresholdException Create the directory if it doesn't exist.- Parameters:
dir- Directory to check for the disk error/full.- Throws:
DiskChecker.DiskErrorException- If disk having errorsDiskChecker.DiskWarnThresholdException- If disk has less than configured amount of free space.DiskChecker.DiskOutOfSpaceException- If disk is full or having less space than threshold
-
setDiskSpaceThreshold
void setDiskSpaceThreshold(float diskSpaceThreshold, float diskUsageWarnThreshold) Set the disk space threshold.- Parameters:
diskSpaceThreshold-
-
getDiskUsageThreshold
public float getDiskUsageThreshold() -
getDiskUsageWarnThreshold
public float getDiskUsageWarnThreshold()
-