Commit 5938c967 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 9cb2a096
...@@ -45,6 +45,7 @@ import org.springframework.context.ApplicationContext; ...@@ -45,6 +45,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -170,20 +171,22 @@ public class EndpointWebMvcManagementContextConfiguration { ...@@ -170,20 +171,22 @@ public class EndpointWebMvcManagementContextConfiguration {
} }
private static class LogFileCondition extends SpringBootCondition { private static class LogFileCondition extends SpringBootCondition {
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) { AnnotatedTypeMetadata metadata) {
String config = context.getEnvironment().resolvePlaceholders( Environment environment = context.getEnvironment();
"${logging.file:}"); String config = environment.resolvePlaceholders("${logging.file:}");
if (StringUtils.hasText(config)) { if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.file: " + config); return ConditionOutcome.match("Found logging.file: " + config);
} }
config = context.getEnvironment().resolvePlaceholders("${logging.path:}"); config = environment.resolvePlaceholders("${logging.path:}");
if (StringUtils.hasText(config)) { if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.path: " + config); return ConditionOutcome.match("Found logging.path: " + config);
} }
return ConditionOutcome.noMatch("Found no log file configuration"); return ConditionOutcome.noMatch("Found no log file configuration");
} }
} }
} }
...@@ -61,8 +61,8 @@ public class HealthEndpoint extends AbstractEndpoint<Health> { ...@@ -61,8 +61,8 @@ public class HealthEndpoint extends AbstractEndpoint<Health> {
} }
/** /**
* Time to live for cached result. This is particularly useful to cache the * Time to live for cached result. This is particularly useful to cache the result of
* result of this endpoint to prevent a DOS attack if it is accessed anonymously. * this endpoint to prevent a DOS attack if it is accessed anonymously.
* @return time to live in milliseconds (default 1000) * @return time to live in milliseconds (default 1000)
*/ */
public long getTimeToLive() { public long getTimeToLive() {
......
...@@ -83,10 +83,6 @@ public class MetricExportProperties extends TriggerProperties { ...@@ -83,10 +83,6 @@ public class MetricExportProperties extends TriggerProperties {
return this.redis; return this.redis;
} }
public void setRedis(Redis redis) {
this.redis = redis;
}
public Aggregate getAggregate() { public Aggregate getAggregate() {
return this.aggregate; return this.aggregate;
} }
...@@ -95,6 +91,10 @@ public class MetricExportProperties extends TriggerProperties { ...@@ -95,6 +91,10 @@ public class MetricExportProperties extends TriggerProperties {
this.aggregate = aggregate; this.aggregate = aggregate;
} }
public void setRedis(Redis redis) {
this.redis = redis;
}
/** /**
* Find a matching trigger configuration. * Find a matching trigger configuration.
* @param name the bean name to match * @param name the bean name to match
...@@ -109,6 +109,44 @@ public class MetricExportProperties extends TriggerProperties { ...@@ -109,6 +109,44 @@ public class MetricExportProperties extends TriggerProperties {
return this; return this;
} }
public static class Aggregate {
/**
* Prefix for global repository if active. Should be unique for this JVM, but most
* useful if it also has the form "a.b" where "a" is unique to this logical
* process (this application) and "b" is unique to this physical process. If you
* set spring.application.name elsewhere, then the default will be in the right
* form.
*/
private String prefix = "";
/**
* Pattern that tells the aggregator what to do with the keys from the source
* repository. The keys in the source repository are assumed to be period
* separated, and the pattern is in the same format, e.g. "d.d.k.d". Here "d"
* means "discard" and "k" means "keep" the key segment in the corresponding
* position in the source.
*/
private String keyPattern = "";
public String getPrefix() {
return this.prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getKeyPattern() {
return this.keyPattern;
}
public void setKeyPattern(String keyPattern) {
this.keyPattern = keyPattern;
}
}
public static class Redis { public static class Redis {
/** /**
...@@ -161,42 +199,4 @@ public class MetricExportProperties extends TriggerProperties { ...@@ -161,42 +199,4 @@ public class MetricExportProperties extends TriggerProperties {
} }
public static class Aggregate {
/**
* Prefix for global repository if active. Should be unique for this JVM, but most
* useful if it also has the form "a.b" where "a" is unique to this logical
* process (this application) and "b" is unique to this physical process. If you
* set spring.application.name elsewhere, then the default will be in the right
* form.
*/
private String prefix = "";
/**
* Pattern that tells the aggregator what to do with the keys from the source
* repository. The keys in the source repository are assumed to be period
* separated, and the pattern is in the same format, e.g. "d.d.k.d". Here "d"
* means "discard" and "k" means "keep" the key segment in the corresponding
* position in the source.
*/
private String keyPattern = "";
public String getPrefix() {
return this.prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getKeyPattern() {
return this.keyPattern;
}
public void setKeyPattern(String keyPattern) {
this.keyPattern = keyPattern;
}
}
} }
...@@ -52,4 +52,5 @@ public class AggregateMetricsConfiguration { ...@@ -52,4 +52,5 @@ public class AggregateMetricsConfiguration {
repository.setKeyPattern(this.export.getAggregate().getKeyPattern()); repository.setKeyPattern(this.export.getAggregate().getKeyPattern());
return repository; return repository;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment