Search in sources :

Example 1 with DaemonStat

use of io.vertigo.commons.daemon.DaemonStat in project vertigo by KleeGroup.

the class DaemonManagerImpl method checkDaemonsExecs.

@HealthChecked(name = "lastExecs", feature = "daemons")
public HealthMeasure checkDaemonsExecs() {
    final List<DaemonStat> daemonStats = getStats();
    final long failureCount = daemonStats.stream().filter(// to have a real indicator we use only daemon that have been executed at least once
    daemonStat -> daemonStat.getCount() > 0).filter(daemonStat -> !daemonStat.isLastExecSuccess()).count();
    // ---
    final HealthMeasureBuilder healthMeasure = HealthMeasure.builder();
    if (failureCount == 0) {
        return healthMeasure.withGreenStatus().build();
    } else if (failureCount < daemonStats.size()) {
        return healthMeasure.withYellowStatus("At least one daemon failed", null).build();
    }
    return healthMeasure.withRedStatus("All daemons failed", null).build();
}
Also used : HealthChecked(io.vertigo.commons.analytics.health.HealthChecked) DaemonDefinition(io.vertigo.commons.daemon.DaemonDefinition) DaemonStat(io.vertigo.commons.daemon.DaemonStat) DaemonManager(io.vertigo.commons.daemon.DaemonManager) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) AnalyticsManager(io.vertigo.commons.analytics.AnalyticsManager) ClassUtil(io.vertigo.util.ClassUtil) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) Definition(io.vertigo.core.definition.Definition) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) HealthMeasureBuilder(io.vertigo.commons.analytics.health.HealthMeasureBuilder) List(java.util.List) Stream(java.util.stream.Stream) Activeable(io.vertigo.core.component.Activeable) SimpleDefinitionProvider(io.vertigo.core.definition.SimpleDefinitionProvider) Assertion(io.vertigo.lang.Assertion) Component(io.vertigo.core.component.Component) HealthMeasure(io.vertigo.commons.analytics.health.HealthMeasure) AopPlugin(io.vertigo.core.component.AopPlugin) Daemon(io.vertigo.commons.daemon.Daemon) DaemonScheduled(io.vertigo.commons.daemon.DaemonScheduled) HealthMeasureBuilder(io.vertigo.commons.analytics.health.HealthMeasureBuilder) DaemonStat(io.vertigo.commons.daemon.DaemonStat) HealthChecked(io.vertigo.commons.analytics.health.HealthChecked)

Aggregations

Home (io.vertigo.app.Home)1 AnalyticsManager (io.vertigo.commons.analytics.AnalyticsManager)1 HealthChecked (io.vertigo.commons.analytics.health.HealthChecked)1 HealthMeasure (io.vertigo.commons.analytics.health.HealthMeasure)1 HealthMeasureBuilder (io.vertigo.commons.analytics.health.HealthMeasureBuilder)1 Daemon (io.vertigo.commons.daemon.Daemon)1 DaemonDefinition (io.vertigo.commons.daemon.DaemonDefinition)1 DaemonManager (io.vertigo.commons.daemon.DaemonManager)1 DaemonScheduled (io.vertigo.commons.daemon.DaemonScheduled)1 DaemonStat (io.vertigo.commons.daemon.DaemonStat)1 Activeable (io.vertigo.core.component.Activeable)1 AopPlugin (io.vertigo.core.component.AopPlugin)1 Component (io.vertigo.core.component.Component)1 Definition (io.vertigo.core.definition.Definition)1 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)1 SimpleDefinitionProvider (io.vertigo.core.definition.SimpleDefinitionProvider)1 Assertion (io.vertigo.lang.Assertion)1 ClassUtil (io.vertigo.util.ClassUtil)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1