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 Duration
private static final Duration
private static final Duration
private static final VariableResolver
private final FileService
private org.eclipse.jetty.client.HttpClient
static final String
private static final org.slf4j.Logger
private final MetaService
private RestClient
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 com.codahale.metrics.Meter
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
<Path> downloadLocalUpdate
(String fileKey) private com.google.common.util.concurrent.ListenableFuture
<Path> downloadRemoteUpdate
(String engine, String fileKey, Path updateDir) private com.google.common.util.concurrent.ListenableFuture
<MetaObject> loadStatus
(String engineId) private WatchdogStatus
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 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, onConfigWatcherNotification, serviceId, 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, handleConfigWatcherNotification, onConfigChanged
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_STATUS_HEALTHY
- See Also:
-
UPDATE_STATUS_UNHEALTHY
- See Also:
-
fileService
-
metaService
-
unhealthyEngines
-
userService
-
checkSchedule
-
httpClient
private org.eclipse.jetty.client.HttpClient httpClient -
restClient
-
sendStatusErrorMeter
private com.codahale.metrics.Meter sendStatusErrorMeter -
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
-
onFileExpirationNotification
-
receiveUpdateStatus
-
loadStatus
-
startUp
- Overrides:
startUp
in classAbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>
- Throws:
Exception
-
sendStatusAndProcessUpdate
private void sendStatusAndProcessUpdate() -
newStatus
-
sendStatus
private com.google.common.util.concurrent.ListenableFuture<WatchdogStatusReply> sendStatus(WatchdogStatus status) -
receiveStatus
public com.google.common.util.concurrent.ListenableFuture<WatchdogStatusReply> receiveStatus(WatchdogStatus status) -
processUpdate
private com.google.common.util.concurrent.ListenableFuture<Void> processUpdate(WatchdogStatusUpdate update) -
downloadLocalUpdate
-
downloadRemoteUpdate
-
checkEngines
private void checkEngines() -
checkRetention
private void checkRetention() -
shutDown
- Overrides:
shutDown
in classAbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>
- Throws:
Exception
-
unhealthyEngines
-