Remove code deprecated in 2.1
See gh-16013
This commit is contained in:
committed by
Stephane Nicoll
parent
5e4418973e
commit
246111cd84
@@ -41,17 +41,6 @@ public interface PathMapper {
|
||||
*/
|
||||
String getRootPath(EndpointId endpointId);
|
||||
|
||||
/**
|
||||
* Returns an {@link PathMapper} that uses the endpoint ID as the path.
|
||||
* @return an {@link PathMapper} that uses the lowercase endpoint ID as the path
|
||||
* @deprecated since 2.1.0 in favor of {@link #getRootPath(List, EndpointId)} with a
|
||||
* {@code null} list
|
||||
*/
|
||||
@Deprecated
|
||||
static PathMapper useEndpointId() {
|
||||
return EndpointId::toString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the root path for the specified {@code endpointId} from the given path
|
||||
* mappers. If no mapper matches then the ID itself is returned.
|
||||
|
||||
@@ -33,17 +33,6 @@ public class CompositeHealthIndicator implements HealthIndicator {
|
||||
|
||||
private final HealthAggregator aggregator;
|
||||
|
||||
/**
|
||||
* Create a new {@link CompositeHealthIndicator}.
|
||||
* @param healthAggregator the health aggregator
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CompositeHealthIndicator(HealthAggregator healthAggregator) {
|
||||
this(healthAggregator, new DefaultHealthIndicatorRegistry());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link CompositeHealthIndicator} from the specified indicators.
|
||||
* @param healthAggregator the health aggregator
|
||||
@@ -67,20 +56,6 @@ public class CompositeHealthIndicator implements HealthIndicator {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given {@code healthIndicator}, associating it with the given {@code name}.
|
||||
* @param name the name of the indicator
|
||||
* @param indicator the indicator
|
||||
* @throws IllegalStateException if an indicator with the given {@code name} is
|
||||
* already registered.
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link HealthIndicatorRegistry#register(String, HealthIndicator)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void addHealthIndicator(String name, HealthIndicator indicator) {
|
||||
this.registry.register(name, indicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link HealthIndicatorRegistry} of this instance.
|
||||
* @return the registry of nested {@link HealthIndicator health indicators}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Factory to create a {@link CompositeHealthIndicator}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link CompositeHealthIndicator#CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CompositeHealthIndicatorFactory {
|
||||
|
||||
private final Function<String, String> healthIndicatorNameFactory;
|
||||
|
||||
public CompositeHealthIndicatorFactory() {
|
||||
this(new HealthIndicatorNameFactory());
|
||||
}
|
||||
|
||||
public CompositeHealthIndicatorFactory(
|
||||
Function<String, String> healthIndicatorNameFactory) {
|
||||
this.healthIndicatorNameFactory = healthIndicatorNameFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link CompositeHealthIndicator} based on the specified health indicators.
|
||||
* @param healthAggregator the {@link HealthAggregator}
|
||||
* @param healthIndicators the {@link HealthIndicator} instances mapped by name
|
||||
* @return a {@link HealthIndicator} that delegates to the specified
|
||||
* {@code healthIndicators}.
|
||||
*/
|
||||
public CompositeHealthIndicator createHealthIndicator(
|
||||
HealthAggregator healthAggregator,
|
||||
Map<String, HealthIndicator> healthIndicators) {
|
||||
Assert.notNull(healthAggregator, "HealthAggregator must not be null");
|
||||
Assert.notNull(healthIndicators, "HealthIndicators must not be null");
|
||||
HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory(
|
||||
this.healthIndicatorNameFactory);
|
||||
return new CompositeHealthIndicator(healthAggregator,
|
||||
factory.createHealthIndicatorRegistry(healthIndicators));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,32 +45,6 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator
|
||||
|
||||
private final Function<Mono<Health>, Mono<Health>> timeoutCompose;
|
||||
|
||||
/**
|
||||
* Create a new {@link CompositeReactiveHealthIndicator}.
|
||||
* @param healthAggregator the health aggregator
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link #CompositeReactiveHealthIndicator(HealthAggregator, ReactiveHealthIndicatorRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CompositeReactiveHealthIndicator(HealthAggregator healthAggregator) {
|
||||
this(healthAggregator, new LinkedHashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link CompositeReactiveHealthIndicator} from the specified
|
||||
* indicators.
|
||||
* @param healthAggregator the health aggregator
|
||||
* @param indicators a map of {@link ReactiveHealthIndicator HealthIndicators} with
|
||||
* the key being used as an indicator name.
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link #CompositeReactiveHealthIndicator(HealthAggregator, ReactiveHealthIndicatorRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CompositeReactiveHealthIndicator(HealthAggregator healthAggregator,
|
||||
Map<String, ReactiveHealthIndicator> indicators) {
|
||||
this(healthAggregator, new DefaultReactiveHealthIndicatorRegistry(indicators));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link CompositeReactiveHealthIndicator} from the indicators in the
|
||||
@@ -86,23 +60,6 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator
|
||||
Duration.ofMillis(this.timeout), Mono.just(this.timeoutHealth)) : mono;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@link ReactiveHealthIndicator} with the specified name.
|
||||
* @param name the name of the health indicator
|
||||
* @param indicator the health indicator to add
|
||||
* @return this instance
|
||||
* @throws IllegalStateException if an indicator with the given {@code name} is
|
||||
* already registered.
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link ReactiveHealthIndicatorRegistry#register(String, ReactiveHealthIndicator)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CompositeReactiveHealthIndicator addHealthIndicator(String name,
|
||||
ReactiveHealthIndicator indicator) {
|
||||
this.registry.register(name, indicator);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify an alternative timeout {@link Health} if a {@link HealthIndicator} failed
|
||||
* to reply after specified {@code timeout}.
|
||||
|
||||
@@ -48,20 +48,6 @@ public class MetricsWebFilter implements WebFilter {
|
||||
|
||||
private final boolean autoTimeRequests;
|
||||
|
||||
/**
|
||||
* Create a new {@code MetricsWebFilter}.
|
||||
* @param registry the registry to which metrics are recorded
|
||||
* @param tagsProvider provider for metrics tags
|
||||
* @param metricName name of the metric to record
|
||||
* @deprecated since 2.0.6 in favor of
|
||||
* {@link #MetricsWebFilter(MeterRegistry, WebFluxTagsProvider, String, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MetricsWebFilter(MeterRegistry registry, WebFluxTagsProvider tagsProvider,
|
||||
String metricName) {
|
||||
this(registry, tagsProvider, metricName, true);
|
||||
}
|
||||
|
||||
public MetricsWebFilter(MeterRegistry registry, WebFluxTagsProvider tagsProvider,
|
||||
String metricName, boolean autoTimeRequests) {
|
||||
this.registry = registry;
|
||||
|
||||
@@ -61,23 +61,6 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
|
||||
|
||||
private final boolean autoTimeRequests;
|
||||
|
||||
/**
|
||||
* Create a new {@link WebMvcMetricsFilter} instance.
|
||||
* @param context the source application context
|
||||
* @param registry the meter registry
|
||||
* @param tagsProvider the tags provider
|
||||
* @param metricName the metric name
|
||||
* @param autoTimeRequests if requests should be automatically timed
|
||||
* @deprecated since 2.0.7 in favor of
|
||||
* {@link #WebMvcMetricsFilter(MeterRegistry, WebMvcTagsProvider, String, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public WebMvcMetricsFilter(ApplicationContext context, MeterRegistry registry,
|
||||
WebMvcTagsProvider tagsProvider, String metricName,
|
||||
boolean autoTimeRequests) {
|
||||
this(registry, tagsProvider, metricName, autoTimeRequests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link WebMvcMetricsFilter} instance.
|
||||
* @param registry the meter registry
|
||||
|
||||
@@ -55,18 +55,6 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code DiskSpaceHealthIndicator} instance.
|
||||
* @param path the Path used to compute the available disk space
|
||||
* @param threshold the minimum disk space that should be available (in bytes)
|
||||
* @deprecated since 2.1.0 in favor of
|
||||
* {@link #DiskSpaceHealthIndicator(File, DataSize)}
|
||||
*/
|
||||
@Deprecated
|
||||
public DiskSpaceHealthIndicator(File path, long threshold) {
|
||||
this(path, DataSize.ofBytes(threshold));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
long diskFreeInBytes = this.path.getUsableSpace();
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompositeHealthIndicatorFactory}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Christian Dupuis
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@Deprecated
|
||||
public class CompositeHealthIndicatorFactoryTests {
|
||||
|
||||
@Test
|
||||
public void upAndUpIsAggregatedToUp() {
|
||||
Map<String, HealthIndicator> healthIndicators = new HashMap<>();
|
||||
healthIndicators.put("up", () -> new Health.Builder().status(Status.UP).build());
|
||||
healthIndicators.put("upAgain",
|
||||
() -> new Health.Builder().status(Status.UP).build());
|
||||
HealthIndicator healthIndicator = createHealthIndicator(healthIndicators);
|
||||
assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.UP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upAndDownIsAggregatedToDown() {
|
||||
Map<String, HealthIndicator> healthIndicators = new HashMap<>();
|
||||
healthIndicators.put("up", () -> new Health.Builder().status(Status.UP).build());
|
||||
healthIndicators.put("down",
|
||||
() -> new Health.Builder().status(Status.DOWN).build());
|
||||
HealthIndicator healthIndicator = createHealthIndicator(healthIndicators);
|
||||
assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownStatusMapsToUnknown() {
|
||||
Map<String, HealthIndicator> healthIndicators = new HashMap<>();
|
||||
healthIndicators.put("status", () -> new Health.Builder().status("FINE").build());
|
||||
HealthIndicator healthIndicator = createHealthIndicator(healthIndicators);
|
||||
assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
|
||||
private HealthIndicator createHealthIndicator(
|
||||
Map<String, HealthIndicator> healthIndicators) {
|
||||
return new CompositeHealthIndicatorFactory()
|
||||
.createHealthIndicator(new OrderedHealthAggregator(), healthIndicators);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user