public static DiagnosticDataPoint of(String service, ZonedDateTime timestamp, boolean alive) { return new DiagnosticDataPoint(service, timestamp, alive); }
private static long aliveAsLong(DiagnosticDataPoint dataPoint) { return dataPoint.alive() ? 1 : 0; }
@Override public DiagnosticDataPoint gatherDataFromService() { // this check should actually contact the serviceName boolean alive = RANDOM.nextFloat() > 0.25; return DiagnosticDataPoint.of(serviceName, ZonedDateTime.now(), alive); }
Statistics merge(DiagnosticDataPoint dataPoint) { Map<String, LivenessQuota> newStatistics = new HashMap<>(livenessQuotaByService); LivenessQuota oldServiceQuota = newStatistics.getOrDefault(dataPoint.service(), LivenessQuota.zero()); newStatistics.put(dataPoint.service(), oldServiceQuota.merge(dataPoint)); LivenessQuota newTotalQuota = totalLivenessQuota.merge(dataPoint); return new Statistics(newTotalQuota, newStatistics); }
@Override public DiagnosticDataPoint gatherDataFromService() { // this check should actually contact the serviceName boolean alive = RANDOM.nextFloat() > 0.1; return DiagnosticDataPoint.of(serviceName, ZonedDateTime.now(), alive); }