use of password.pwm.svc.PwmService in project pwm by pwm-project.
the class HealthMonitor method doHealthChecks.
private void doHealthChecks() {
if (status != STATUS.OPEN) {
return;
}
final TimeDuration timeSinceLastUpdate = TimeDuration.fromCurrent(lastHealthCheckTime);
if (timeSinceLastUpdate.isShorterThan(settings.getMinimumCheckInterval().getTotalMilliseconds(), TimeUnit.MILLISECONDS)) {
return;
}
final Instant startTime = Instant.now();
LOGGER.trace("beginning background health check process");
final List<HealthRecord> tempResults = new ArrayList<>();
for (final HealthChecker loopChecker : HEALTH_CHECKERS) {
try {
final List<HealthRecord> loopResults = loopChecker.doHealthCheck(pwmApplication);
if (loopResults != null) {
tempResults.addAll(loopResults);
}
} catch (Exception e) {
if (status == STATUS.OPEN) {
LOGGER.warn("unexpected error during healthCheck: " + e.getMessage(), e);
}
}
}
for (final PwmService service : pwmApplication.getPwmServices()) {
try {
final List<HealthRecord> loopResults = service.healthCheck();
if (loopResults != null) {
tempResults.addAll(loopResults);
}
} catch (Exception e) {
if (status == STATUS.OPEN) {
LOGGER.warn("unexpected error during healthCheck: " + e.getMessage(), e);
}
}
}
healthRecords.clear();
healthRecords.addAll(tempResults);
lastHealthCheckTime = Instant.now();
LOGGER.trace("health check process completed (" + TimeDuration.fromCurrent(startTime).asCompactString() + ")");
}
use of password.pwm.svc.PwmService in project pwm by pwm-project.
the class AppDashboardData method getServiceData.
private static List<ServiceData> getServiceData(final PwmApplication pwmApplication) {
final Map<String, ServiceData> returnData = new TreeMap<>();
for (final PwmService pwmService : pwmApplication.getPwmServices()) {
final PwmService.ServiceInfo serviceInfo = pwmService.serviceInfo();
final Collection<DataStorageMethod> storageMethods = serviceInfo == null ? Collections.emptyList() : serviceInfo.getUsedStorageMethods() == null ? Collections.emptyList() : serviceInfo.getUsedStorageMethods();
final Map<String, String> debugData = serviceInfo == null ? Collections.emptyMap() : serviceInfo.getDebugProperties() == null ? Collections.emptyMap() : serviceInfo.getDebugProperties();
returnData.put(pwmService.getClass().getSimpleName(), new ServiceData(pwmService.getClass().getSimpleName(), pwmService.status(), storageMethods, pwmService.healthCheck(), debugData));
}
return Collections.unmodifiableList(new ArrayList<>(returnData.values()));
}
Aggregations