use of io.vertigo.commons.analytics.health.HealthCheck in project vertigo by KleeGroup.
the class DaemonManagerTest method testSimple.
@Test
public void testSimple() throws Exception {
DaemonStat daemonStat = daemonManager.getStats().stream().filter(stat -> FakeComponent.SIMPLE_DAEMON_NAME.equals(stat.getDaemonName())).findFirst().get();
assertEquals(0, daemonStat.getCount());
assertEquals(0, daemonStat.getFailures());
assertEquals(0, daemonStat.getSuccesses());
assertEquals(DaemonStat.Status.pending, daemonStat.getStatus());
assertEquals(0, fakeComponent.getExecutionCount());
// -----
// soit deux execs
Thread.sleep(5000);
daemonStat = daemonManager.getStats().stream().filter(stat -> FakeComponent.SIMPLE_DAEMON_NAME.equals(stat.getDaemonName())).findFirst().get();
assertEquals(2, daemonStat.getCount());
assertEquals(1, daemonStat.getFailures());
assertEquals(1, daemonStat.getSuccesses());
assertEquals(DaemonStat.Status.pending, daemonStat.getStatus());
assertTrue(fakeComponent.getExecutionCount() > 0);
final HealthCheck daemonsExecHealthCheck = analyticsManager.getHealthChecks().stream().filter(healtChk -> "daemons".equals(healtChk.getFeature()) && "lastExecs".equals(healtChk.getName())).findFirst().get();
assertTrue(daemonsExecHealthCheck.getMeasure().getStatus() == HealthStatus.GREEN);
}
use of io.vertigo.commons.analytics.health.HealthCheck in project vertigo by KleeGroup.
the class HealthAnalyticsUtil method aggregate.
public static HealthStatus aggregate(final List<HealthCheck> healthChecks) {
Assertion.checkNotNull(healthChecks);
// ---
int nbGreen = 0;
int nbYellow = 0;
int nbRed = 0;
for (final HealthCheck healthCheck : healthChecks) {
switch(healthCheck.getMeasure().getStatus()) {
case GREEN:
nbGreen++;
break;
case YELLOW:
nbYellow++;
break;
case RED:
nbRed++;
break;
default:
break;
}
}
return generateStatus(nbGreen, nbYellow, nbRed);
}
Aggregations