use of org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator in project cas by apereo.
the class CasCoreMonitorConfiguration method sessionHealthIndicator.
@ConditionalOnMissingBean(name = "sessionHealthIndicator")
@Bean
@ConditionalOnEnabledHealthIndicator("sessionHealthIndicator")
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public HealthIndicator sessionHealthIndicator(@Qualifier(TicketRegistry.BEAN_NAME) final TicketRegistry ticketRegistry, final CasConfigurationProperties casProperties) {
val warnSt = casProperties.getMonitor().getSt().getWarn();
val warnTgt = casProperties.getMonitor().getTgt().getWarn();
if (warnSt.getThreshold() > 0 && warnTgt.getThreshold() > 0) {
LOGGER.debug("Configured session monitor with service ticket threshold [{}] and session threshold [{}]", warnSt.getThreshold(), warnTgt.getThreshold());
return new TicketRegistryHealthIndicator(ticketRegistry, warnSt.getThreshold(), warnTgt.getThreshold());
}
return () -> Health.up().build();
}
use of org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator in project cas by apereo.
the class MongoDbMonitoringConfiguration method mongoHealthIndicator.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnEnabledHealthIndicator("mongoHealthIndicator")
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
public HealthIndicator mongoHealthIndicator(final CasConfigurationProperties casProperties, @Qualifier("mongoHealthIndicatorTemplate") final BeanContainer<CasMongoOperations> mongoHealthIndicatorTemplate) {
val warn = casProperties.getMonitor().getWarn();
val results = mongoHealthIndicatorTemplate.toList().stream().map(template -> new MongoDbHealthIndicator(template, warn.getEvictionThreshold(), warn.getThreshold())).collect(Collectors.toList());
return new CompositeHealthIndicator(results);
}
use of org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator in project cas by apereo.
the class LdapMonitorConfiguration method pooledLdapConnectionFactoryHealthIndicator.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnEnabledHealthIndicator("pooledLdapConnectionFactoryHealthIndicator")
public CompositeHealthContributor pooledLdapConnectionFactoryHealthIndicator(final CasConfigurationProperties casProperties, @Qualifier("pooledLdapConnectionFactoryHealthIndicatorListFactoryBean") final ListFactoryBean factoryBean) throws Exception {
val ldaps = casProperties.getMonitor().getLdap();
val connectionFactoryList = Objects.requireNonNull(factoryBean.getObject());
val contributors = new LinkedHashMap<>();
ldaps.stream().filter(LdapMonitorProperties::isEnabled).map(Unchecked.function(ldap -> {
val executor = Beans.newThreadPoolExecutorFactoryBean(ldap.getPool());
val connectionFactory = LdapUtils.newLdaptivePooledConnectionFactory(ldap);
connectionFactoryList.add(connectionFactory);
val healthIndicator = new PooledLdapConnectionFactoryHealthIndicator(Beans.newDuration(ldap.getMaxWait()).toMillis(), connectionFactory, executor.getObject(), new SearchConnectionValidator());
val name = StringUtils.defaultIfBlank(ldap.getName(), UUID.randomUUID().toString());
return Pair.of(name, healthIndicator);
})).forEach(it -> contributors.put(it.getKey(), it.getValue()));
return CompositeHealthContributor.fromMap((Map) contributors);
}
Aggregations