Class FileDescriptorStatusProvider
- All Implemented Interfaces:
HealthProvider,StatusProvider
StatusProvider, the open file descriptors out of the most the
process can open, such as File descriptors: 812/65536, and as a HealthProvider, for the systemd watchdog, reporting the application as
unhealthy when they are about to run out, if enabled.
Every open file, socket and pipe takes a file descriptor, and once they run out, the application can no longer accept connections or open files.
As a leak of file descriptors never resolves by itself, restarting the application is usually the only way out. The limit is the one systemd sets with
LimitNOFILE in the service unit.
The health is enabled on its own, as it lets systemd restart the application: while disabled, the application is always healthy. When enabled, it is
unhealthy while the open file descriptors are at or above the given share of the limit, reporting both in the health details, under
openFileDescriptors and maxFileDescriptors. As a burst of connections can also open many file descriptors for a short while, the
unhealthy state can be delayed, with DelayableHealthProvider.setUnhealthyDelay(java.time.Duration).
The file descriptors are only known on Unix-like systems, and nothing is reported otherwise.
- Author:
- Joao Silva
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.jpmsilva.jsystemd.HealthProvider
HealthProvider.Health -
Constructor Summary
ConstructorsConstructorDescriptionFileDescriptorStatusProvider(boolean health, double threshold) Create a new FileDescriptorStatusProvider. -
Method Summary
Modifier and TypeMethodDescriptionprotected HealthProvider.HealthProvides the health of the application, without the delay: unhealthy while the open file descriptors are at or above the threshold, if enabled.status()Exposes status information to send to systemd.Methods inherited from class com.github.jpmsilva.jsystemd.DelayableHealthProvider
getUnhealthyDelay, health, setUnhealthyDelay
-
Constructor Details
-
FileDescriptorStatusProvider
public FileDescriptorStatusProvider(boolean health, double threshold) Create a new FileDescriptorStatusProvider.- Parameters:
health-trueto report the application as unhealthy when the file descriptors are about to run outthreshold- the share of the limit of file descriptors from which the application is unhealthy, such as0.9for 90%- Throws:
IllegalArgumentException- if the threshold is not greater than 0 and at most 1
-
-
Method Details
-
status
Description copied from interface:StatusProviderExposes status information to send to systemd.- Specified by:
statusin interfaceStatusProvider- Returns:
- the string message to add to the service status
-
evaluateHealth
Provides the health of the application, without the delay: unhealthy while the open file descriptors are at or above the threshold, if enabled.- Specified by:
evaluateHealthin classDelayableHealthProvider- Returns:
- the health of the application
-