Class DiskSpaceGuard
The exporter should stop writing before the destination disk becomes critically full. This guard preserves a 1 GiB safety reserve on the target volume and centralizes the status/log behavior for low-disk write refusals.
When the disk/file sink is the only active sink, low disk stops export entirely via
ExportReporterLifecycle.stopAndClearPendingExportWork(). When OpenSearch remains
enabled, this guard refuses only the local disk write and leaves OpenSearch export running.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classException used when a disk write is refused due to low available space. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longMaximum managed-disk usage for spill and other exporter-owned storage.static final longMinimum free bytes that must remain on the destination volume after a write. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidensureWritable(Path target, long bytesToWrite, String context) Ensures the destination volume has enough free space for a write.static voidClears low-disk throttling state and test overrides.static voidsetUsableSpaceOverride(Function<Path, Long> override) Visible-for-tests override for usable space calculation.
-
Field Details
-
MAX_MANAGED_BYTES
public static final long MAX_MANAGED_BYTESMaximum managed-disk usage for spill and other exporter-owned storage.- See Also:
-
MIN_FREE_BYTES
public static final long MIN_FREE_BYTESMinimum free bytes that must remain on the destination volume after a write.- See Also:
-
-
Method Details
-
ensureWritable
public static void ensureWritable(Path target, long bytesToWrite, String context) throws IOException Ensures the destination volume has enough free space for a write.The check preserves a 1 GiB reserve after the write completes. On failure this method logs the event, posts the appropriate control status, and may stop export when the current sink selection means disk is the only active sink. Caller may invoke from any thread.
- Parameters:
target- path being written, or its containing directorybytesToWrite- estimated write size in bytescontext- short context for logs and user-facing status- Throws:
IOException- when the disk cannot be checked or the write should be refused
-
setUsableSpaceOverride
Visible-for-tests override for usable space calculation.Tests may force low-disk scenarios without filling the real disk. Production code should leave this unset.
- Parameters:
override- replacement usable-space resolver, ornullto clear
-
resetForTests
public static void resetForTests()Clears low-disk throttling state and test overrides.Intended for test teardown so one scenario does not leak notification state into the next test.
-