Package org.apache.bookkeeper.util
Class DiskChecker
- java.lang.Object
-
- org.apache.bookkeeper.util.DiskChecker
-
public class DiskChecker extends java.lang.Object
Class that provides utility functions for checking disk problems.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DiskChecker.DiskErrorException
A disk error exception.static class
DiskChecker.DiskException
A general marker for disk-related exceptions.static class
DiskChecker.DiskOutOfSpaceException
An out-of-space disk exception.static class
DiskChecker.DiskWarnThresholdException
A 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 float
checkDir(java.io.File dir)
Create the directory if it doesn't exist.(package private) float
checkDiskFull(java.io.File dir)
Checks the disk space available.float
getDiskUsageThreshold()
float
getDiskUsageWarnThreshold()
long
getTotalDiskSpace(java.util.List<java.io.File> dirs)
Calculate the total amount of disk space in all of the ledger directories put together.float
getTotalDiskUsage(java.util.List<java.io.File> dirs)
calculates and returns the disk usage factor in the provided list of dirs.long
getTotalFreeSpace(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) void
setDiskSpaceThreshold(float diskSpaceThreshold, float diskUsageWarnThreshold)
Set the disk space threshold.
-
-
-
Method Detail
-
checkDiskFull
float checkDiskFull(java.io.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.DiskOutOfSpaceException
if available space is less than threshold.DiskChecker.DiskWarnThresholdException
-
getTotalFreeSpace
public long getTotalFreeSpace(java.util.List<java.io.File> dirs) throws java.io.IOException
Calculate 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.IOException
Calculate 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.IOException
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:
java.io.IOException
-
checkDir
public float checkDir(java.io.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()
-
-