Package org.apache.bookkeeper.util
Class DiskChecker
- java.lang.Object
-
- org.apache.bookkeeper.util.DiskChecker
-
public class DiskChecker extends java.lang.ObjectClass that provides utility functions for checking disk problems.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiskChecker.DiskErrorExceptionA disk error exception.static classDiskChecker.DiskExceptionA general marker for disk-related exceptions.static classDiskChecker.DiskOutOfSpaceExceptionAn out-of-space disk exception.static classDiskChecker.DiskWarnThresholdExceptionA disk warn threshold exception.
-
Constructor Summary
Constructors Constructor Description DiskChecker(float threshold, float warnThreshold)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatcheckDir(java.io.File dir)Create the directory if it doesn't exist.(package private) floatcheckDiskFull(java.io.File dir)Checks the disk space available.floatgetDiskUsageThreshold()floatgetDiskUsageWarnThreshold()longgetTotalDiskSpace(java.util.List<java.io.File> dirs)Calculate the total amount of disk space in all of the ledger directories put together.floatgetTotalDiskUsage(java.util.List<java.io.File> dirs)calculates and returns the disk usage factor in the provided list of dirs.longgetTotalFreeSpace(java.util.List<java.io.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.
-
-
-
Method Detail
-
checkDiskFull
float checkDiskFull(java.io.File dir) throws DiskChecker.DiskOutOfSpaceException, DiskChecker.DiskWarnThresholdExceptionChecks 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
public long getTotalFreeSpace(java.util.List<java.io.File> dirs) throws java.io.IOExceptionCalculate the total amount of free space available in all of the ledger directories put together.- Returns:
- freeDiskSpace in bytes
- Throws:
java.io.IOException
-
getTotalDiskSpace
public long getTotalDiskSpace(java.util.List<java.io.File> dirs) throws java.io.IOExceptionCalculate the total amount of disk space in all of the ledger directories put together.- Returns:
- totalDiskSpace in bytes
- Throws:
java.io.IOException
-
getTotalDiskUsage
public float getTotalDiskUsage(java.util.List<java.io.File> dirs) throws java.io.IOExceptioncalculates 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:
java.io.IOException
-
checkDir
public float checkDir(java.io.File dir) throws DiskChecker.DiskErrorException, DiskChecker.DiskOutOfSpaceException, DiskChecker.DiskWarnThresholdExceptionCreate 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()
-
-