Deprecate Cassandra health indicators that rely on Spring Data
With the introduction of health indicators that only require the CqlSession, this commit deprecates the health indicators that require Spring Data since the latter build on top of the former. Closes gh-23226
This commit is contained in:
parent
b1a843279a
commit
b9b7393053
|
|
@ -19,9 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.cassandra;
|
|||
import com.datastax.oss.driver.api.core.CqlSession;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.cassandra.CassandraHealthContributorConfigurations.CassandraDriverConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.cassandra.CassandraHealthContributorConfigurations.CassandraOperationsConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
|
|
@ -32,7 +31,7 @@ import org.springframework.context.annotation.Import;
|
|||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for
|
||||
* {@link CassandraHealthIndicator}.
|
||||
* {@link CassandraDriverHealthIndicator}.
|
||||
*
|
||||
* @author Julien Dubois
|
||||
* @author Stephane Nicoll
|
||||
|
|
@ -43,7 +42,9 @@ import org.springframework.context.annotation.Import;
|
|||
@ConditionalOnEnabledHealthIndicator("cassandra")
|
||||
@AutoConfigureAfter({ CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class,
|
||||
CassandraReactiveHealthContributorAutoConfiguration.class })
|
||||
@Import({ CassandraOperationsConfiguration.class, CassandraDriverConfiguration.class })
|
||||
@Import({ CassandraDriverConfiguration.class,
|
||||
CassandraHealthContributorConfigurations.CassandraOperationsConfiguration.class })
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CassandraHealthContributorAutoConfiguration {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthCont
|
|||
import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthContributorConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthContributor;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthContributor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
|
@ -59,8 +57,9 @@ class CassandraHealthContributorConfigurations {
|
|||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(CassandraOperations.class)
|
||||
@ConditionalOnBean(CassandraOperations.class)
|
||||
static class CassandraOperationsConfiguration
|
||||
extends CompositeHealthContributorConfiguration<CassandraHealthIndicator, CassandraOperations> {
|
||||
@Deprecated
|
||||
static class CassandraOperationsConfiguration extends
|
||||
CompositeHealthContributorConfiguration<org.springframework.boot.actuate.cassandra.CassandraHealthIndicator, CassandraOperations> {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = { "cassandraHealthIndicator", "cassandraHealthContributor" })
|
||||
|
|
@ -86,8 +85,9 @@ class CassandraHealthContributorConfigurations {
|
|||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ReactiveCassandraOperations.class)
|
||||
@ConditionalOnBean(ReactiveCassandraOperations.class)
|
||||
@Deprecated
|
||||
static class CassandraReactiveOperationsConfiguration extends
|
||||
CompositeReactiveHealthContributorConfiguration<CassandraReactiveHealthIndicator, ReactiveCassandraOperations> {
|
||||
CompositeReactiveHealthContributorConfiguration<org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator, ReactiveCassandraOperations> {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = { "cassandraHealthIndicator", "cassandraHealthContributor" })
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@ import com.datastax.oss.driver.api.core.CqlSession;
|
|||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.cassandra.CassandraHealthContributorConfigurations.CassandraReactiveDriverConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.cassandra.CassandraHealthContributorConfigurations.CassandraReactiveOperationsConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
|
@ -31,7 +30,7 @@ import org.springframework.context.annotation.Import;
|
|||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for
|
||||
* {@link CassandraReactiveHealthIndicator}.
|
||||
* {@link CassandraDriverReactiveHealthIndicator}.
|
||||
*
|
||||
* @author Artsiom Yudovin
|
||||
* @author Stephane Nicoll
|
||||
|
|
@ -41,7 +40,9 @@ import org.springframework.context.annotation.Import;
|
|||
@ConditionalOnClass({ CqlSession.class, Flux.class })
|
||||
@ConditionalOnEnabledHealthIndicator("cassandra")
|
||||
@AutoConfigureAfter(CassandraReactiveDataAutoConfiguration.class)
|
||||
@Import({ CassandraReactiveOperationsConfiguration.class, CassandraReactiveDriverConfiguration.class })
|
||||
@Import({ CassandraReactiveDriverConfiguration.class,
|
||||
CassandraHealthContributorConfigurations.CassandraReactiveOperationsConfiguration.class })
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CassandraReactiveHealthContributorAutoConfiguration {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
|
@ -36,6 +35,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class CassandraHealthContributorAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
|
|
@ -45,21 +45,31 @@ class CassandraHealthContributorAutoConfigurationTests {
|
|||
@Test
|
||||
void runWithoutCqlSessionOrCassandraOperationsShouldNotCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class).doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCassandraOperationsShouldCreateRegularIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionOnlyShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class)).run((context) -> assertThat(context)
|
||||
.hasSingleBean(CassandraDriverHealthIndicator.class).doesNotHaveBean(CassandraHealthIndicator.class));
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCassandraOperationsOnlyShouldCreateRegularIndicator() {
|
||||
this.contextRunner.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionAndCassandraOperationsShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -67,7 +77,7 @@ class CassandraHealthContributorAutoConfigurationTests {
|
|||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withClassLoader(new FilteredClassLoader("org.springframework.data"))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class));
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -76,7 +86,7 @@ class CassandraHealthContributorAutoConfigurationTests {
|
|||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
|
@ -39,6 +37,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Artsiom Yudovin
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
|
|
@ -48,37 +47,50 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
|||
@Test
|
||||
void runWithoutCqlSessionOrReactiveCassandraOperationsShouldNotCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithReactiveCassandraOperationsShouldOnlyCreateReactiveIndicator() {
|
||||
void runWithCqlSessionOnlyShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class).doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithReactiveCassandraOperationsOnlyShouldCreateReactiveIndicator() {
|
||||
this.contextRunner.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraReactiveHealthIndicator.class)
|
||||
.hasSingleBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionShouldCreateDriverIndicator() {
|
||||
void runWithCqlSessionAndReactiveCassandraOperationsShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraReactiveHealthIndicator.class));
|
||||
.doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionAndSpringDataAbsentShouldACreateDriverIndicator() {
|
||||
void runWithCqlSessionAndSpringDataAbsentShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withClassLoader(new FilteredClassLoader("org.springframework.data"))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraReactiveHealthIndicator.class));
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class).doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -86,8 +98,8 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
|||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraReactiveHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor").doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ import org.springframework.util.Assert;
|
|||
* @author Julien Dubois
|
||||
* @author Alexandre Dutra
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.4.0 in favor of {@link CassandraDriverHealthIndicator}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CassandraHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
private static final SimpleStatement SELECT = SimpleStatement
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ import org.springframework.util.Assert;
|
|||
*
|
||||
* @author Artsiom Yudovin
|
||||
* @since 2.1.0
|
||||
* @deprecated since 2.4.0 in favor of {@link CassandraDriverHealthIndicator}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CassandraReactiveHealthIndicator extends AbstractReactiveHealthIndicator {
|
||||
|
||||
private static final SimpleStatement SELECT = SimpleStatement
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Oleksii Bondar
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class CassandraHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import static org.mockito.Mockito.mock;
|
|||
*
|
||||
* @author Artsiom Yudovin
|
||||
*/
|
||||
@Deprecated
|
||||
class CassandraReactiveHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -679,7 +679,7 @@ with the `key` listed in the table below.
|
|||
|
||||
=======
|
||||
| `cassandra`
|
||||
| {spring-boot-actuator-module-code}/cassandra/CassandraHealthIndicator.java[`CassandraHealthIndicator`] or {spring-boot-actuator-module-code}/cassandra/CassandraDriverHealthIndicator.java[`CassandraDriverHealthIndicator`]
|
||||
| {spring-boot-actuator-module-code}/cassandra/CassandraDriverHealthIndicator.java[`CassandraDriverHealthIndicator`]
|
||||
| Checks that a Cassandra database is up.
|
||||
|
||||
| `couchbase`
|
||||
|
|
@ -878,7 +878,7 @@ The following `ReactiveHealthIndicators` are auto-configured by Spring Boot when
|
|||
|===
|
||||
| Name | Description
|
||||
|
||||
| {spring-boot-actuator-module-code}/cassandra/CassandraReactiveHealthIndicator.java[`CassandraReactiveHealthIndicator`] or {spring-boot-actuator-module-code}/cassandra/CassandraDriverReactiveHealthIndicator.java[`CassandraDriverReactiveHealthIndicator`]
|
||||
| {spring-boot-actuator-module-code}/cassandra/CassandraDriverReactiveHealthIndicator.java[`CassandraDriverReactiveHealthIndicator`]
|
||||
| Checks that a Cassandra database is up.
|
||||
|
||||
| {spring-boot-actuator-module-code}/couchbase/CouchbaseReactiveHealthIndicator.java[`CouchbaseReactiveHealthIndicator`]
|
||||
|
|
|
|||
Loading…
Reference in New Issue