public final class StorageMonitor
extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
StorageMonitor.State
State.
|
static interface |
StorageMonitor.StateTransitionHandler
State transition handler.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
FREE_ALERT_PROPERTY
Free alert property.
|
static String |
FREE_WARN_PROPERTY
Free warn property.
|
static String |
ROOT_DIR_PROPERTY
Root dir property.
|
| Constructor and Description |
|---|
StorageMonitor(Logger logger)
Constructs an instance.
|
StorageMonitor(Logger logger,
Optional<StorageMonitor.StateTransitionHandler> onWarn,
Optional<StorageMonitor.StateTransitionHandler> onAlert)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
check()
Checks.
|
long |
getAvailable()
Gets the available space size in bytes from the last check.
|
int |
getFree()
Gets the free space size in million bytes from the last check.
|
StorageMonitor.State |
getState()
Gets the state.
|
boolean |
setUp(KeyedValues storageProperties,
File defaultRootDir)
Sets up this.
|
void |
setUsableSpaceSupplier(LongSupplier usableSpaceSupplier)
Sets the usable space supplier.
|
void |
tearDown()
Tears down what as been set up.
|
public static final String FREE_ALERT_PROPERTY
public static final String FREE_WARN_PROPERTY
public static final String ROOT_DIR_PROPERTY
public StorageMonitor(@Nonnull
Logger logger)
logger - A logger.public StorageMonitor(@Nonnull
Logger logger,
@Nonnull
Optional<StorageMonitor.StateTransitionHandler> onWarn,
@Nonnull
Optional<StorageMonitor.StateTransitionHandler> onAlert)
When the transition handler predicate is called, it returns false to let the storage monitor log a message (also logged if the handler is null).
logger - A logger.onWarn - Called on 'warn' transition.onAlert - Called on 'alert' transition.@CheckReturnValue public boolean check()
@CheckReturnValue public long getAvailable()
@CheckReturnValue public int getFree()
@CheckReturnValue public StorageMonitor.State getState()
@CheckReturnValue
public boolean setUp(@Nonnull
KeyedValues storageProperties,
@Nonnull
File defaultRootDir)
storageProperties - The storage properties.defaultRootDir - The default root directory.public void setUsableSpaceSupplier(@Nonnull
LongSupplier usableSpaceSupplier)
Used by storage monitor tests.
usableSpaceSupplier - The usable space supplier.public void tearDown()
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.