Merge branch '2.3.x'
This commit is contained in:
commit
da69286838
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -23,8 +23,11 @@ import reactor.core.publisher.Mono;
|
|||
import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* {@link HealthIndicator} for an Elasticsearch cluster using a
|
||||
|
@ -50,28 +53,28 @@ public class ElasticsearchReactiveHealthIndicator extends AbstractReactiveHealth
|
|||
|
||||
@Override
|
||||
protected Mono<Health> doHealthCheck(Health.Builder builder) {
|
||||
return this.client.execute((callback) -> callback.get().uri("/_cluster/health/").exchange())
|
||||
.flatMap((response) -> {
|
||||
if (response.statusCode().is2xxSuccessful()) {
|
||||
return response.bodyToMono(STRING_OBJECT_MAP).map((body) -> {
|
||||
String status = (String) body.get("status");
|
||||
if (RED_STATUS.equals(status)) {
|
||||
builder.outOfService();
|
||||
}
|
||||
else {
|
||||
builder.up();
|
||||
}
|
||||
builder.withDetails(body);
|
||||
return builder.build();
|
||||
});
|
||||
}
|
||||
else {
|
||||
builder.down();
|
||||
builder.withDetail("statusCode", response.rawStatusCode());
|
||||
builder.withDetail("reasonPhrase", response.statusCode().getReasonPhrase());
|
||||
return response.releaseBody().thenReturn(builder.build());
|
||||
}
|
||||
});
|
||||
return this.client.execute(this::getHealth).flatMap((response) -> doHealthCheck(builder, response));
|
||||
}
|
||||
|
||||
private Mono<ClientResponse> getHealth(WebClient webClient) {
|
||||
return webClient.get().uri("/_cluster/health/").exchange();
|
||||
}
|
||||
|
||||
private Mono<Health> doHealthCheck(Health.Builder builder, ClientResponse response) {
|
||||
if (response.statusCode().is2xxSuccessful()) {
|
||||
return response.bodyToMono(STRING_OBJECT_MAP).map((body) -> getHealth(builder, body));
|
||||
}
|
||||
builder.down();
|
||||
builder.withDetail("statusCode", response.rawStatusCode());
|
||||
builder.withDetail("reasonPhrase", response.statusCode().getReasonPhrase());
|
||||
return response.releaseBody().thenReturn(builder.build());
|
||||
}
|
||||
|
||||
private Health getHealth(Health.Builder builder, Map<String, Object> body) {
|
||||
String status = (String) body.get("status");
|
||||
builder.status(RED_STATUS.equals(status) ? Status.OUT_OF_SERVICE : Status.UP);
|
||||
builder.withDetails(body);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.actuate.redis;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
|
@ -39,15 +37,7 @@ import org.springframework.util.Assert;
|
|||
*/
|
||||
public class RedisHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
static final String VERSION = "version";
|
||||
|
||||
static final String CLUSTER_SIZE = "cluster_size";
|
||||
|
||||
static final String SLOTS_UP = "slots_up";
|
||||
|
||||
static final String SLOTS_FAIL = "slots_fail";
|
||||
|
||||
static final String REDIS_VERSION = "redis_version";
|
||||
private static final String REDIS_VERSION_PROPERTY = "redis_version";
|
||||
|
||||
private final RedisConnectionFactory redisConnectionFactory;
|
||||
|
||||
|
@ -61,20 +51,24 @@ public class RedisHealthIndicator extends AbstractHealthIndicator {
|
|||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
RedisConnection connection = RedisConnectionUtils.getConnection(this.redisConnectionFactory);
|
||||
try {
|
||||
if (connection instanceof RedisClusterConnection) {
|
||||
ClusterInfo clusterInfo = ((RedisClusterConnection) connection).clusterGetClusterInfo();
|
||||
builder.up().withDetail(CLUSTER_SIZE, clusterInfo.getClusterSize())
|
||||
.withDetail(SLOTS_UP, clusterInfo.getSlotsOk())
|
||||
.withDetail(SLOTS_FAIL, clusterInfo.getSlotsFail());
|
||||
}
|
||||
else {
|
||||
Properties info = connection.info();
|
||||
builder.up().withDetail(VERSION, info.getProperty(REDIS_VERSION));
|
||||
}
|
||||
doHealthCheck(builder, connection);
|
||||
}
|
||||
finally {
|
||||
RedisConnectionUtils.releaseConnection(connection, this.redisConnectionFactory, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void doHealthCheck(Health.Builder builder, RedisConnection connection) {
|
||||
if (connection instanceof RedisClusterConnection) {
|
||||
ClusterInfo clusterInfo = ((RedisClusterConnection) connection).clusterGetClusterInfo();
|
||||
builder.up().withDetail("cluster_size", clusterInfo.getClusterSize())
|
||||
.withDetail("slots_up", clusterInfo.getSlotsOk())
|
||||
.withDetail("slots_fail", clusterInfo.getSlotsFail());
|
||||
}
|
||||
else {
|
||||
String version = connection.info().getProperty(REDIS_VERSION_PROPERTY);
|
||||
builder.up().withDetail("version", version);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
|||
*/
|
||||
public class RedisReactiveHealthIndicator extends AbstractReactiveHealthIndicator {
|
||||
|
||||
private static final String REDIS_VERSION_PROPERTY = "redis_version";
|
||||
|
||||
private final ReactiveRedisConnectionFactory connectionFactory;
|
||||
|
||||
public RedisReactiveHealthIndicator(ReactiveRedisConnectionFactory connectionFactory) {
|
||||
|
@ -59,11 +61,9 @@ public class RedisReactiveHealthIndicator extends AbstractReactiveHealthIndicato
|
|||
.onErrorResume((ex) -> Mono.just(down(builder, ex)))
|
||||
.flatMap((health) -> clusterConnection.closeLater().thenReturn(health));
|
||||
}
|
||||
else {
|
||||
return connection.serverCommands().info().map((info) -> up(builder, info))
|
||||
.onErrorResume((ex) -> Mono.just(down(builder, ex)))
|
||||
.flatMap((health) -> connection.closeLater().thenReturn(health));
|
||||
}
|
||||
return connection.serverCommands().info().map((info) -> up(builder, info))
|
||||
.onErrorResume((ex) -> Mono.just(down(builder, ex)))
|
||||
.flatMap((health) -> connection.closeLater().thenReturn(health));
|
||||
}
|
||||
|
||||
private Mono<ReactiveRedisConnection> getConnection() {
|
||||
|
@ -72,14 +72,13 @@ public class RedisReactiveHealthIndicator extends AbstractReactiveHealthIndicato
|
|||
}
|
||||
|
||||
private Health up(Health.Builder builder, Properties info) {
|
||||
return builder.up()
|
||||
.withDetail(RedisHealthIndicator.VERSION, info.getProperty(RedisHealthIndicator.REDIS_VERSION)).build();
|
||||
return builder.up().withDetail("version", info.getProperty(REDIS_VERSION_PROPERTY)).build();
|
||||
}
|
||||
|
||||
private Health up(Health.Builder builder, ClusterInfo clusterInfo) {
|
||||
return builder.up().withDetail(RedisHealthIndicator.CLUSTER_SIZE, clusterInfo.getClusterSize())
|
||||
.withDetail(RedisHealthIndicator.SLOTS_UP, clusterInfo.getSlotsOk())
|
||||
.withDetail(RedisHealthIndicator.SLOTS_FAIL, clusterInfo.getSlotsFail()).build();
|
||||
return builder.up().withDetail("cluster_size", clusterInfo.getClusterSize())
|
||||
.withDetail("slots_up", clusterInfo.getSlotsOk()).withDetail("slots_fail", clusterInfo.getSlotsFail())
|
||||
.build();
|
||||
}
|
||||
|
||||
private Health down(Health.Builder builder, Throwable cause) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -95,7 +95,7 @@ dependencies {
|
|||
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||
testImplementation("org.assertj:assertj-core")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
|
||||
|
||||
testRuntimeOnly(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
|
||||
testRuntimeOnly("com.h2database:h2")
|
||||
testRuntimeOnly("org.springframework:spring-jdbc")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
|
@ -69,8 +69,10 @@ final class LocalHttpClientTransport extends HttpClientTransport {
|
|||
|
||||
private static String socketFilePath(Environment environment) {
|
||||
String host = environment.get(DOCKER_HOST);
|
||||
return (host != null && host.startsWith(UNIX_SOCKET_PREFIX)) ? host.substring(UNIX_SOCKET_PREFIX.length())
|
||||
: host;
|
||||
if (host != null && host.startsWith(UNIX_SOCKET_PREFIX)) {
|
||||
return host.substring(UNIX_SOCKET_PREFIX.length());
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ZipFileTarArchive implements TarArchive {
|
|||
|
||||
private void assertArchiveHasEntries(File jarFile) {
|
||||
try (ZipFile zipFile = new ZipFile(jarFile)) {
|
||||
Assert.state(zipFile.getEntries().hasMoreElements(), "File '" + jarFile.toString()
|
||||
Assert.state(zipFile.getEntries().hasMoreElements(), () -> "File '" + jarFile
|
||||
+ "' is not compatible with buildpacks; ensure jar file is valid and launch script is not enabled");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
Loading…
Reference in New Issue