mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '1.1.x'
Conflicts: spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepository.java
This commit is contained in:
commit
872f30e5d0
@ -58,7 +58,7 @@ public class RedisMetricRepository implements MetricRepository {
|
||||
* Create a RedisMetricRepository with a default prefix to apply to all metric names.
|
||||
* If multiple repositories share a redis instance they will feed into the same global
|
||||
* metrics.
|
||||
*
|
||||
*
|
||||
* @param redisConnectionFactory the redis connection factory
|
||||
*/
|
||||
public RedisMetricRepository(RedisConnectionFactory redisConnectionFactory) {
|
||||
@ -70,7 +70,7 @@ public class RedisMetricRepository implements MetricRepository {
|
||||
* unique to this repository or to a logical repository contributed to by multiple
|
||||
* instances, where they all see the same values). Recommended constructor for general
|
||||
* purpose use.
|
||||
*
|
||||
*
|
||||
* @param redisConnectionFactory the redis connection factory
|
||||
* @param prefix the prefix to set for all metrics keys
|
||||
*/
|
||||
@ -84,7 +84,7 @@ public class RedisMetricRepository implements MetricRepository {
|
||||
* redis store will hold a zset under the key just so the metric names can be
|
||||
* enumerated. Read operations, especially {@link #findAll()} and {@link #count()},
|
||||
* will only be accurate if the key is unique to the prefix of this repository.
|
||||
*
|
||||
*
|
||||
* @param redisConnectionFactory the redis connection factory
|
||||
* @param prefix the prefix to set for all metrics keys
|
||||
* @param key the key to set
|
||||
|
@ -26,13 +26,12 @@ import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.SystemPropertyUtils;
|
||||
|
||||
/**
|
||||
* An {@link org.springframework.context.ApplicationListener} that saves application PID
|
||||
* into file. This application listener will be triggered exactly once per JVM, and the file
|
||||
* name can be overridden at runtime with a System property or environment variable named
|
||||
* "PIDFILE" (or "pidfile").
|
||||
* into file. This application listener will be triggered exactly once per JVM, and the
|
||||
* file name can be overridden at runtime with a System property or environment variable
|
||||
* named "PIDFILE" (or "pidfile").
|
||||
*
|
||||
* @author Jakub Kubrynski
|
||||
* @author Dave Syer
|
||||
@ -46,6 +45,8 @@ public class ApplicationPidListener implements
|
||||
|
||||
private static final String DEFAULT_FILE_NAME = "application.pid";
|
||||
|
||||
private static final String[] PROPERTY_VARIABLES = { "PIDFILE", "pidfile" };
|
||||
|
||||
private static final AtomicBoolean created = new AtomicBoolean(false);
|
||||
|
||||
private int order = Ordered.HIGHEST_PRECEDENCE + 13;
|
||||
@ -74,10 +75,30 @@ public class ApplicationPidListener implements
|
||||
*/
|
||||
public ApplicationPidListener(File file) {
|
||||
Assert.notNull(file, "File must not be null");
|
||||
String actual = SystemPropertyUtils.resolvePlaceholders("${PIDFILE}", true);
|
||||
actual = !actual.contains("$") ? actual : SystemPropertyUtils.resolvePlaceholders("${pidfile}", true);
|
||||
actual = !actual.contains("$") ? actual : file.getAbsolutePath();
|
||||
this.file = new File(actual);
|
||||
String override = getOverride();
|
||||
if (override != null) {
|
||||
this.file = new File(override);
|
||||
}
|
||||
else {
|
||||
this.file = file;
|
||||
}
|
||||
}
|
||||
|
||||
private String getOverride() {
|
||||
for (String property : PROPERTY_VARIABLES) {
|
||||
try {
|
||||
String override = System.getProperty(property);
|
||||
override = (override != null ? override : System.getenv(property));
|
||||
if (override != null) {
|
||||
return override;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
System.err.println("Could not resolve '" + property
|
||||
+ "' as system property: " + ex);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,9 @@ public class ApplicationPidListenerTests {
|
||||
System.setProperty("PIDFILE", this.temporaryFolder.newFile().getAbsolutePath());
|
||||
ApplicationPidListener listener = new ApplicationPidListener(file);
|
||||
listener.onApplicationEvent(EVENT);
|
||||
assertThat(FileCopyUtils.copyToString(new FileReader(System.getProperty("PIDFILE"))), not(isEmptyString()));
|
||||
assertThat(
|
||||
FileCopyUtils.copyToString(new FileReader(System.getProperty("PIDFILE"))),
|
||||
not(isEmptyString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -465,11 +465,11 @@ HTTPS connector:
|
||||
|
||||
[[howto-use-tomcat-behind-a-proxy-server]]
|
||||
=== Use Tomcat behind a front-end proxy server
|
||||
Spring Boot will automatically configure Tomcat's `RemoteIpValve` if you enable it. This allows you to
|
||||
transparently use the standard `x-forwarded-for` and `x-forwarded-proto` headers that
|
||||
most front-end proxy servers add. The valve is switched on by setting one or both of these
|
||||
properties to something non-empty (these are the conventional values used by most proxies, and if
|
||||
you only set one the other will be set automatically):
|
||||
Spring Boot will automatically configure Tomcat's `RemoteIpValve` if you enable it. This
|
||||
allows you to transparently use the standard `x-forwarded-for` and `x-forwarded-proto`
|
||||
headers that most front-end proxy servers add. The valve is switched on by setting one or
|
||||
both of these properties to something non-empty (these are the conventional values used by
|
||||
most proxies, and if you only set one the other will be set automatically):
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
@ -477,9 +477,8 @@ you only set one the other will be set automatically):
|
||||
server.tomcat.protocol_header=x-forwarded-protocol
|
||||
----
|
||||
|
||||
If your proxy uses different headers you can
|
||||
customize the valve's configuration by adding some entries to `application.properties`,
|
||||
e.g.
|
||||
If your proxy uses different headers you can customize the valve's configuration by adding
|
||||
some entries to `application.properties`, e.g.
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
|
Loading…
Reference in New Issue
Block a user