public class Systemd extends Object implements AutoCloseable
Implements and exposes most of the sd_notify
protocol, as well as some convenience methods.
Since this object sets up some timers for periodic communication with systemd, client code is expected to call close()
then they no longer need
Systemd instances. The implementation also implements AutoCloseable
to ease implementation in DI containers that support the semantic.
Modifier and Type | Class and Description |
---|---|
static class |
Systemd.Builder
Specialized build class of
Systemd objects. |
Modifier and Type | Method and Description |
---|---|
void |
addStatusProviders(int index,
List<SystemdNotifyStatusProvider> providers)
Adds the status providers to the the list of providers in the specified position.
|
void |
addStatusProviders(int index,
SystemdNotifyStatusProvider... providers)
Adds the status providers to the the list of providers in the specified position.
|
void |
addStatusProviders(SystemdNotifyStatusProvider... providers)
Adds the status providers to the end of the list of providers.
|
static Systemd.Builder |
builder()
Provides a dedicated builder instance that knows how to create Systemd instances.
|
void |
close() |
void |
extendTimeout()
Forces the timeout to be extended.
|
List<SystemdNotifyStatusProvider> |
getStatusProviders()
Returns a read only view of the current providers.
|
boolean |
isReady()
Returns if the application as completed startup.
|
void |
ready()
Notifies systemd that the unit is ready.
|
void |
setStatusProviders(List<SystemdNotifyStatusProvider> providers)
Sets the current providers, unregistering any other previously added.
|
void |
updateStatus()
Forces the current status to be calculated and sent to systemd.
|
void |
watchdog()
Forces the watchdog timestamp to be updated.
|
public static Systemd.Builder builder()
public void addStatusProviders(int index, SystemdNotifyStatusProvider... providers)
index
- position to add the providersproviders
- the providers to addpublic void addStatusProviders(SystemdNotifyStatusProvider... providers)
providers
- the providers to addpublic void addStatusProviders(int index, List<SystemdNotifyStatusProvider> providers)
index
- position to add the providersproviders
- the providers to addpublic List<SystemdNotifyStatusProvider> getStatusProviders()
public void setStatusProviders(List<SystemdNotifyStatusProvider> providers)
providers
- the providers to setpublic void updateStatus()
enableStatusUpdate(long, TimeUnit)
can be used to enable
periodic status updates.public void extendTimeout()
enableExtendTimeout(long, TimeUnit, long)
, or 29 seconds if otherwise. Timeout extensions can only be sent during startup.public void watchdog()
enableWatchdog(long, TimeUnit)
can be used to enable periodic watchdog
updates.public void ready()
public boolean isReady()
true
if and only if ready
has been called.public void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2017–2018. All rights reserved.