Rename SimpleDataSourceHealthIndicator
Rename SimpleDataSourceHealthIndicator to DataSourceHealthIndicator.
This commit is contained in:
parent
aa03d9a41c
commit
96a0d672af
|
|
@ -26,13 +26,13 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.actuate.health.CompositeHealthIndicator;
|
import org.springframework.boot.actuate.health.CompositeHealthIndicator;
|
||||||
|
import org.springframework.boot.actuate.health.DataSourceHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.HealthAggregator;
|
import org.springframework.boot.actuate.health.HealthAggregator;
|
||||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
|
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
|
||||||
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.SimpleDataSourceHealthIndicator;
|
|
||||||
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
|
|
@ -100,15 +100,14 @@ public class HealthIndicatorAutoConfiguration {
|
||||||
@ConditionalOnMissingBean(name = "dbHealthIndicator")
|
@ConditionalOnMissingBean(name = "dbHealthIndicator")
|
||||||
public HealthIndicator dbHealthIndicator() {
|
public HealthIndicator dbHealthIndicator() {
|
||||||
if (this.dataSources.size() == 1) {
|
if (this.dataSources.size() == 1) {
|
||||||
return new SimpleDataSourceHealthIndicator(this.dataSources.values()
|
return new DataSourceHealthIndicator(this.dataSources.values().iterator()
|
||||||
.iterator().next());
|
.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositeHealthIndicator composite = new CompositeHealthIndicator(
|
CompositeHealthIndicator composite = new CompositeHealthIndicator(
|
||||||
this.healthAggregator);
|
this.healthAggregator);
|
||||||
for (Map.Entry<String, DataSource> entry : this.dataSources.entrySet()) {
|
for (Map.Entry<String, DataSource> entry : this.dataSources.entrySet()) {
|
||||||
composite.addHealthIndicator(entry.getKey(),
|
composite.addHealthIndicator(entry.getKey(),
|
||||||
new SimpleDataSourceHealthIndicator(entry.getValue()));
|
new DataSourceHealthIndicator(entry.getValue()));
|
||||||
}
|
}
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,13 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple implementation of {@link HealthIndicator} that returns a status and also
|
* {@link HealthIndicator} that tests the status of a {@link DataSource} and optionally
|
||||||
* attempts a simple database test.
|
* runs a test query.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Christian Dupuis
|
* @author Christian Dupuis
|
||||||
*/
|
*/
|
||||||
public class SimpleDataSourceHealthIndicator extends AbstractHealthIndicator {
|
public class DataSourceHealthIndicator extends AbstractHealthIndicator {
|
||||||
|
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
|
@ -55,17 +55,16 @@ public class SimpleDataSourceHealthIndicator extends AbstractHealthIndicator {
|
||||||
private String query = null;
|
private String query = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link SimpleDataSourceHealthIndicator} instance.
|
* Create a new {@link DataSourceHealthIndicator} instance.
|
||||||
*/
|
*/
|
||||||
public SimpleDataSourceHealthIndicator() {
|
public DataSourceHealthIndicator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link SimpleDataSourceHealthIndicator} using the specified
|
* Create a new {@link DataSourceHealthIndicator} using the specified datasource.
|
||||||
* datasource.
|
|
||||||
* @param dataSource the data source
|
* @param dataSource the data source
|
||||||
*/
|
*/
|
||||||
public SimpleDataSourceHealthIndicator(DataSource dataSource) {
|
public DataSourceHealthIndicator(DataSource dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ import org.springframework.boot.actuate.health.HealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.SimpleDataSourceHealthIndicator;
|
import org.springframework.boot.actuate.health.DataSourceHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
||||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||||
|
|
@ -149,7 +149,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||||
Map<String, HealthIndicator> beans = this.context
|
Map<String, HealthIndicator> beans = this.context
|
||||||
.getBeansOfType(HealthIndicator.class);
|
.getBeansOfType(HealthIndicator.class);
|
||||||
assertEquals(1, beans.size());
|
assertEquals(1, beans.size());
|
||||||
assertEquals(SimpleDataSourceHealthIndicator.class, beans.values().iterator()
|
assertEquals(DataSourceHealthIndicator.class, beans.values().iterator()
|
||||||
.next().getClass());
|
.next().getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link SimpleDataSourceHealthIndicator}.
|
* Tests for {@link DataSourceHealthIndicator}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
public class SimpleDataSourceHealthIndicatorTests {
|
public class DataSourceHealthIndicatorTests {
|
||||||
|
|
||||||
private final SimpleDataSourceHealthIndicator indicator = new SimpleDataSourceHealthIndicator();
|
private final DataSourceHealthIndicator indicator = new DataSourceHealthIndicator();
|
||||||
|
|
||||||
private DriverManagerDataSource dataSource;
|
private DriverManagerDataSource dataSource;
|
||||||
|
|
||||||
Loading…
Reference in New Issue