Class EngineRuntime

java.lang.Object
ch.rswk.meta.engine.EngineRuntime
All Implemented Interfaces:
Executor

@Singleton public class EngineRuntime extends Object implements 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.

  • Field Details

    • WATCH_SCHEDULE

      public static final Duration WATCH_SCHEDULE
    • LOG

      private static final org.slf4j.Logger LOG
    • RUNTIME_METRIC_PREFIX

      private static final String RUNTIME_METRIC_PREFIX
      See Also:
    • SERVICE_NAME_JOINER

      private static final Collector<CharSequence, ?, String> SERVICE_NAME_JOINER
    • UNHEALTHY_SERVICE_STATES

      private static final Predicate<com.google.common.util.concurrent.Service.State> UNHEALTHY_SERVICE_STATES
    • alertRegistry

      private final AlertRegistry alertRegistry
    • config

      private final EngineRuntime.EngineRuntimeConfig config
    • eventBus

      private final com.google.common.eventbus.EventBus 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
    • scheduledTasks

      private final ScheduledTasks scheduledTasks
    • scheduler

      private final com.github.benmanes.caffeine.cache.Scheduler scheduler
    • serviceManagerProvider

      private final javax.inject.Provider<com.google.common.util.concurrent.ServiceManager> serviceManagerProvider
    • watchService

      private final WatchService watchService
    • watchersByFileName

      private final Map<String, EngineRuntime.FileWatcher> watchersByFileName
    • running

      private volatile boolean running
    • startDateTime

      private OffsetDateTime startDateTime
  • Constructor Details

    • EngineRuntime

      @Inject public EngineRuntime(AlertRegistry alertRegistry, EngineRuntime.EngineRuntimeConfig config, com.google.common.eventbus.EventBus eventBus, com.google.common.util.concurrent.ListeningExecutorService executor, com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry, com.codahale.metrics.MetricRegistry metricRegistry, javax.inject.Provider<com.google.common.util.concurrent.ServiceManager> serviceManagerProvider, Set<EngineRuntime.FileWatcher> watchers)
  • Method Details

    • registerFileWatcher

      public void registerFileWatcher(EngineRuntime.FileWatcher watcher)
    • alertRegistry

      public AlertRegistry alertRegistry()
    • awaitServicesRunning

      public boolean awaitServicesRunning(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)
    • awaitServicesTerminated

      public boolean awaitServicesTerminated(com.google.common.util.concurrent.Service... services)
    • cancelFuture

      public static void cancelFuture(@Nullable Future<?> f)
    • eventBus

      public com.google.common.eventbus.EventBus eventBus()
    • execute

      public void execute(Runnable command)
      Specified by:
      execute in interface Executor
    • getServiceInfo

      public com.fasterxml.jackson.databind.node.ObjectNode getServiceInfo()
    • getUptime

      public Duration getUptime()
    • getServices

      public <T> List<T> getServices(Class<T> type)
    • getServiceName

      private String getServiceName(Object service)
    • getUnhealthyService

      public Set<String> getUnhealthyService()
    • getWatchService

      private static WatchService getWatchService()
    • healthCheckRegistry

      public com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry()
    • isHealthy

      public boolean isHealthy()
    • isServiceManagerHealthy

      public boolean isServiceManagerHealthy()
    • metricRegistry

      public com.codahale.metrics.MetricRegistry metricRegistry()
    • newHealthCheckRegistry

      public static com.codahale.metrics.health.HealthCheckRegistry newHealthCheckRegistry()
    • newMetricRegistry

      public static com.codahale.metrics.MetricRegistry newMetricRegistry()
    • putStatsMetrics

      private static void putStatsMetrics(Map<String, com.codahale.metrics.Metric> metrics, com.github.benmanes.caffeine.cache.stats.CacheStats stats)
    • scheduledTasks

      public ScheduledTasks scheduledTasks()
    • scheduler

      public com.github.benmanes.caffeine.cache.Scheduler scheduler()
    • startUp

      public void startUp()
    • shutDown

      public void shutDown()
    • shutdownAndAwaitTermination

      public void shutdownAndAwaitTermination(ExecutorService executor)
    • checkForFileChanges

      private void checkForFileChanges()
    • submit

      public <T> com.google.common.util.concurrent.ListenableFuture<T> submit(Callable<T> task)
      See Also:
      • ListeningExecutorService.submit(Callable)
    • submit

      public void submit(Runnable task)
      See Also:
      • ListeningExecutorService.submit(Runnable)