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 classstatic final recordstatic final recordstatic final recordNested 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 Stringprivate Durationprivate static final Durationprivate static final Durationprivate static final VariableResolverprivate final FileServiceprivate org.eclipse.jetty.client.HttpClientstatic final Stringprivate static final org.slf4j.Loggerprivate final MetaServiceprivate RestClientprivate com.codahale.metrics.Meterprivate static final Stringprivate static final Stringprivate static final com.fasterxml.jackson.databind.JsonNodeprivate static final Stringprivate static final com.fasterxml.jackson.databind.ObjectReaderprivate static final com.fasterxml.jackson.databind.JsonNodeprivate static final com.fasterxml.jackson.databind.ObjectWriterprivate com.codahale.metrics.Meterprivate static final Stringprivate static final Stringprivate com.codahale.metrics.Meterprivate final UserServiceFields 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 voidprivate voidprivate 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 WatchdogStatusvoidprivate com.google.common.util.concurrent.ListenableFuture<Void> processUpdate(WatchdogStatusUpdate update) com.google.common.util.concurrent.ListenableFuture<WatchdogStatusReply> receiveStatus(WatchdogStatus status) voidreceiveUpdateStatus(WatchdogStatusUpdateStatus updateStatus) private com.google.common.util.concurrent.ListenableFuture<WatchdogStatusReply> sendStatus(WatchdogStatus status) private voidprotected voidshutDown()protected voidstartUp()Methods inherited from class ch.rswk.meta.engine.AbstractEngineIdleService
configClass, configReference, onConfigWatcherNotification, serviceId, serviceNameMethods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, startAsync, state, stopAsync, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.rswk.meta.engine.EngineServices.ConfigurableService
config, handleConfigWatcherNotification, onConfigChangedMethods 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:
startUpin 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:
shutDownin classAbstractEngineIdleService<WatchdogService.WatchdogServiceConfig>- Throws:
Exception
-
unhealthyEngines
-