Package ch.rswk.meta.engine
Class WatchdogService
java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
ch.rswk.meta.engine.AbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>
ch.rswk.meta.engine.WatchdogService
- All Implemented Interfaces:
EngineServices.ConfigurableService<WatchdogService.WatchdogServiceConfig>
,EngineServices.InfoProvidingService
,com.google.common.util.concurrent.Service
@Singleton
public class WatchdogService
extends AbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>
WatchdogService can report engine health to another engine (usually a central, dedicated watchdog), check if other runtimes are healthy
(as the dedicated watchdog) and schedule/process automated updates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
static final record
static final record
static final record
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private ScheduledFuture
<?> private Duration
private static final Duration
private static final Duration
private static final VariableResolver
private io.reactivex.rxjava3.disposables.Disposable
private final FileService
private org.eclipse.jetty.client.HttpClient
static final String
private static final org.slf4j.Logger
private final MetaService
private RestClient
private ScheduledFuture
<?> private com.codahale.metrics.Meter
private static final String
private static final String
private static final com.fasterxml.jackson.databind.JsonNode
private static final String
private static final com.fasterxml.jackson.databind.ObjectReader
private static final com.fasterxml.jackson.databind.JsonNode
private static final com.fasterxml.jackson.databind.ObjectWriter
private ScheduledFuture
<?> private com.codahale.metrics.Meter
private static final String
private static final String
private static final String
private com.codahale.metrics.Meter
private final UserService
Fields inherited from class ch.rswk.meta.engine.AbstractEngineIdleService
runtime
-
Constructor Summary
ConstructorsConstructorDescriptionWatchdogService
(WatchdogService.WatchdogServiceConfig config, FileService fileService, MetaService metaService, EngineRuntime runtime, UserService userService) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
private com.google.common.util.concurrent.ListenableFuture
<Void> downloadLocalUpdate
(String fileKey, Path updateFile) private com.google.common.util.concurrent.ListenableFuture
<Void> downloadRemoteUpdate
(String engine, String fileKey, Path updateFile) private com.google.common.util.concurrent.ListenableFuture
<MetaObject> loadStatus
(String engineId) private WatchdogStatus
void
private void
private com.google.common.util.concurrent.ListenableFuture
<Void> processUpdate
(WatchdogStatusUpdate update) com.google.common.util.concurrent.ListenableFuture
<WatchdogStatusReply> receiveStatus
(WatchdogStatus status) void
receiveUpdateStatus
(WatchdogStatusUpdateStatus updateStatus) private void
private com.google.common.util.concurrent.ListenableFuture
<WatchdogStatusReply> sendStatus
(WatchdogStatus status) private void
protected void
shutDown()
protected void
startUp()
Methods inherited from class ch.rswk.meta.engine.AbstractEngineIdleService
configClass, configReference, serviceName
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, startAsync, state, stopAsync, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.rswk.meta.engine.EngineServices.ConfigurableService
config
Methods inherited from interface ch.rswk.meta.engine.EngineServices.InfoProvidingService
getServiceInfo
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
LOCALHOST_REPORT_ENGINE
- See Also:
-
CHECK_LOG_QUERY_FORMAT
- See Also:
-
DEFAULT_CHECK_SCHEDULE
-
DEFAULT_REPORT_SCHEDULE
-
ENGINE_RESOLVER
-
STATUS_BASE_QUERY
- See Also:
-
STATUS_ENGINE_ID_QUERY_FORMAT
- See Also:
-
STATUS_HEALTHY_UPDATE
private static final com.fasterxml.jackson.databind.JsonNode STATUS_HEALTHY_UPDATE -
STATUS_LOG_PURGE
-
STATUS_LOG_QUERY_FORMAT
-
STATUS_REPLY_READER
private static final com.fasterxml.jackson.databind.ObjectReader STATUS_REPLY_READER -
STATUS_UNHEALTHY_UPDATE
private static final com.fasterxml.jackson.databind.JsonNode STATUS_UNHEALTHY_UPDATE -
STATUS_WRITER
private static final com.fasterxml.jackson.databind.ObjectWriter STATUS_WRITER -
UPDATE_ARCHIVE_FILE
- See Also:
-
UPDATE_STATUS_HEALTHY
- See Also:
-
UPDATE_STATUS_UNHEALTHY
- See Also:
-
fileService
-
metaService
-
unhealthyEngines
-
userService
-
checkHandle
-
checkSchedule
-
fileExpirationSub
private io.reactivex.rxjava3.disposables.Disposable fileExpirationSub -
httpClient
private org.eclipse.jetty.client.HttpClient httpClient -
restClient
-
retentionHandle
-
sendStatusErrorMeter
private com.codahale.metrics.Meter sendStatusErrorMeter -
statusHandle
-
statusMeter
private com.codahale.metrics.Meter statusMeter -
updateStatusMeter
private com.codahale.metrics.Meter updateStatusMeter
-
-
Constructor Details
-
WatchdogService
@Inject public WatchdogService(WatchdogService.WatchdogServiceConfig config, FileService fileService, MetaService metaService, EngineRuntime runtime, UserService userService)
-
-
Method Details
-
startUp
- Overrides:
startUp
in classAbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>
- Throws:
Exception
-
shutDown
- Overrides:
shutDown
in classAbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>
- Throws:
Exception
-
onConfigChanged
public void onConfigChanged() -
scheduleReportAndCheckHandles
private void scheduleReportAndCheckHandles() -
sendStatusAndProcessUpdate
private void sendStatusAndProcessUpdate() -
newStatus
-
sendStatus
private com.google.common.util.concurrent.ListenableFuture<WatchdogStatusReply> sendStatus(WatchdogStatus status) -
processUpdate
private com.google.common.util.concurrent.ListenableFuture<Void> processUpdate(WatchdogStatusUpdate update) -
downloadLocalUpdate
-
downloadRemoteUpdate
-
receiveStatus
public com.google.common.util.concurrent.ListenableFuture<WatchdogStatusReply> receiveStatus(WatchdogStatus status) -
receiveUpdateStatus
-
loadStatus
-
checkEngines
private void checkEngines() -
unhealthyEngines
-
checkRetention
private void checkRetention() -
onFileExpirationNotification
-