Package ch.rswk.meta.engine
Class EngineRuntime
java.lang.Object
ch.rswk.meta.engine.EngineRuntime
- All Implemented Interfaces:
Executor
EngineRuntime provides executor services,
ServiceManager
for service lifecycle, centralized access to
Metric,
Health-Check and AlertRegistry
.
Implements Executor
to provide convenience to submit and handle async tasks. See
ListenableFuture.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static final record
static final record
static final record
private static class
private static class
static final record
static interface
private static class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AlertRegistry
private final EngineRuntime.EngineRuntimeConfig
private static final Duration
private final EngineEventBus
private final com.google.common.util.concurrent.ListeningExecutorService
private final com.codahale.metrics.health.HealthCheckRegistry
private static final org.slf4j.Logger
private final com.codahale.metrics.MetricRegistry
private static final int
private boolean
private static final String
private final com.google.common.util.concurrent.ListeningScheduledExecutorService
private final com.github.benmanes.caffeine.cache.Scheduler
private static final Collector
<CharSequence, ?, String> private final javax.inject.Provider
<com.google.common.util.concurrent.ServiceManager> private OffsetDateTime
private static final Predicate
<com.google.common.util.concurrent.Service.State> static final int
private final Map
<String, EngineRuntime.FileWatcher> private ScheduledFuture
<?> private final WatchService
-
Constructor Summary
ConstructorsConstructorDescriptionEngineRuntime
(AlertRegistry alertRegistry, EngineRuntime.EngineRuntimeConfig config, EngineEventBus eventBus, com.google.common.util.concurrent.ListeningExecutorService executor, com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry, com.codahale.metrics.MetricRegistry metricRegistry, com.google.common.util.concurrent.ListeningScheduledExecutorService scheduledExecutor, javax.inject.Provider<com.google.common.util.concurrent.ServiceManager> serviceManagerProvider, Set<EngineRuntime.FileWatcher> watchers) -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
awaitServices
(Consumer<com.google.common.util.concurrent.Service> await, com.google.common.util.concurrent.Service... services) boolean
awaitServicesRunning
(com.google.common.util.concurrent.Service... services) boolean
awaitServicesTerminated
(com.google.common.util.concurrent.Service... services) static void
cancelFuture
(@Nullable Future<?> f) private void
eventBus()
void
com.fasterxml.jackson.databind.node.ObjectNode
private String
getServiceName
(Object service) <T> List
<T> getServices
(Class<T> type) private static WatchService
com.codahale.metrics.health.HealthCheckRegistry
boolean
boolean
com.codahale.metrics.MetricRegistry
static com.codahale.metrics.health.HealthCheckRegistry
static com.codahale.metrics.MetricRegistry
private static void
putStatsMetrics
(Map<String, com.codahale.metrics.Metric> metrics, com.github.benmanes.caffeine.cache.stats.CacheStats stats) void
com.google.common.util.concurrent.ListenableScheduledFuture
<?> <T> com.google.common.util.concurrent.ListenableScheduledFuture
<T> com.google.common.util.concurrent.ListenableScheduledFuture
<?> scheduleAtFixedRate
(Runnable command, Duration initialDelay, Duration period) com.google.common.util.concurrent.ListenableScheduledFuture
<?> scheduleDaily
(Runnable command, int hour, int minute) com.google.common.util.concurrent.ListenableScheduledFuture
<?> scheduleNightly
(Runnable command) com.github.benmanes.caffeine.cache.Scheduler
com.google.common.util.concurrent.ListenableScheduledFuture
<?> scheduleWithFixedDelay
(Runnable command, Duration delay, Duration initialDelay) void
shutDown()
void
shutdownAndAwaitTermination
(ExecutorService executor) void
startUp()
void
<T> com.google.common.util.concurrent.ListenableFuture
<T>
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
WATCH_DELAY
public static final int WATCH_DELAY- See Also:
-
DAILY_SCHEDULE
-
MIN_DAILY_DELAY
private static final int MIN_DAILY_DELAY- See Also:
-
RUNTIME_METRIC_PREFIX
- See Also:
-
SERVICE_NAME_JOINER
-
UNHEALTHY_SERVICE_STATES
private static final Predicate<com.google.common.util.concurrent.Service.State> UNHEALTHY_SERVICE_STATES -
alertRegistry
-
config
-
eventBus
-
executor
private final com.google.common.util.concurrent.ListeningExecutorService executor -
healthCheckRegistry
private final com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry -
metricRegistry
private final com.codahale.metrics.MetricRegistry metricRegistry -
scheduledExecutor
private final com.google.common.util.concurrent.ListeningScheduledExecutorService scheduledExecutor -
scheduler
private final com.github.benmanes.caffeine.cache.Scheduler scheduler -
serviceManagerProvider
private final javax.inject.Provider<com.google.common.util.concurrent.ServiceManager> serviceManagerProvider -
watchService
-
watchersByFileName
-
running
private volatile boolean running -
startDateTime
-
watchHandle
-
-
Constructor Details
-
EngineRuntime
@Inject public EngineRuntime(AlertRegistry alertRegistry, EngineRuntime.EngineRuntimeConfig config, EngineEventBus eventBus, com.google.common.util.concurrent.ListeningExecutorService executor, com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry, com.codahale.metrics.MetricRegistry metricRegistry, com.google.common.util.concurrent.ListeningScheduledExecutorService scheduledExecutor, javax.inject.Provider<com.google.common.util.concurrent.ServiceManager> serviceManagerProvider, Set<EngineRuntime.FileWatcher> watchers)
-
-
Method Details
-
startUp
public void startUp() -
registerFileWatcher
-
checkForFileChanges
private void checkForFileChanges() -
getServiceInfo
public com.fasterxml.jackson.databind.node.ObjectNode getServiceInfo() -
getServiceName
-
awaitServicesRunning
public boolean awaitServicesRunning(com.google.common.util.concurrent.Service... services) -
awaitServicesTerminated
public boolean awaitServicesTerminated(com.google.common.util.concurrent.Service... services) -
awaitServices
private static boolean awaitServices(Consumer<com.google.common.util.concurrent.Service> await, com.google.common.util.concurrent.Service... services) -
shutDown
public void shutDown() -
cancelFuture
-
shutdownAndAwaitTermination
-
eventBus
-
metricRegistry
public com.codahale.metrics.MetricRegistry metricRegistry() -
healthCheckRegistry
public com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry() -
alertRegistry
-
isHealthy
public boolean isHealthy() -
isServiceManagerHealthy
public boolean isServiceManagerHealthy() -
getUptime
-
getUnhealthyService
-
getServices
-
submit
- See Also:
-
submit
- See Also:
-
schedule
public com.google.common.util.concurrent.ListenableScheduledFuture<?> schedule(Runnable command, Duration delay) - See Also:
-
schedule
public <T> com.google.common.util.concurrent.ListenableScheduledFuture<T> schedule(Callable<T> callable, Duration delay) - See Also:
-
scheduleAtFixedRate
public com.google.common.util.concurrent.ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, Duration initialDelay, Duration period) - See Also:
-
scheduleWithFixedDelay
public com.google.common.util.concurrent.ListenableScheduledFuture<?> scheduleWithFixedDelay(Runnable command, Duration delay, Duration initialDelay) - See Also:
-
scheduleNightly
public com.google.common.util.concurrent.ListenableScheduledFuture<?> scheduleNightly(Runnable command) -
scheduleDaily
public com.google.common.util.concurrent.ListenableScheduledFuture<?> scheduleDaily(Runnable command, int hour, int minute) -
execute
-
scheduler
public com.github.benmanes.caffeine.cache.Scheduler scheduler() -
getWatchService
-
newMetricRegistry
public static com.codahale.metrics.MetricRegistry newMetricRegistry() -
putStatsMetrics
-
newHealthCheckRegistry
public static com.codahale.metrics.health.HealthCheckRegistry newHealthCheckRegistry()
-