Commit 0f759da9 by Johannes Edmeier

Add AdminServerConfigurationProperties

parent c973e3af
......@@ -228,6 +228,20 @@ spring.boot.admin.password
[[spring-boot-admin-server]]
== Spring Boot Admin Server ==
.Spring Boot Admin Server configuration options
|===
| Property name |Description |Default value
| spring.boot.admin.monitor.period
| Time interval in ms to update the status of applications with expired status-informations.
| 10.000
| spring.boot.admin.status-lifetime
| Lifetime of iapplication statuses in ms. The applications /health-endpoint will not be queried until the lifetime has expired.
| 10.000
|===
[[spring-cloud-discovery-support]]
=== Spring Cloud Discovery support ===
......
package de.codecentric.boot.admin.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("spring.boot.admin")
public class AdminServerProperties {
private MonitorProperties monitor = new MonitorProperties();
public MonitorProperties getMonitor() {
return monitor;
}
public static class MonitorProperties {
/**
* Time interval in ms to update the status of applications with expired statusInfo
*/
private long period = 10_000L;
/**
* Lifetime of status in ms. The status won't be updated as long the last status isn't
* expired.
*/
private long statusLifetime = 10_000L;
public void setPeriod(long period) {
this.period = period;
}
public long getPeriod() {
return period;
}
public void setStatusLifetime(long statusLifetime) {
this.statusLifetime = statusLifetime;
}
public long getStatusLifetime() {
return statusLifetime;
}
}
}
......@@ -18,9 +18,8 @@ package de.codecentric.boot.admin.config;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
......@@ -54,6 +53,7 @@ import de.codecentric.boot.admin.registry.store.ApplicationStore;
import de.codecentric.boot.admin.registry.store.SimpleApplicationStore;
@Configuration
@EnableConfigurationProperties
public class AdminServerWebConfiguration extends WebMvcConfigurerAdapter
implements ApplicationContextAware {
......@@ -65,8 +65,11 @@ public class AdminServerWebConfiguration extends WebMvcConfigurerAdapter
@Autowired
private ApplicationStore applicationStore;
@Value("${spring.boot.admin.monitor.period:10000}")
private long monitorPeriod;
@Bean
@ConditionalOnMissingBean
public AdminServerProperties adminServerProperties() {
return new AdminServerProperties();
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
......@@ -119,7 +122,6 @@ public class AdminServerWebConfiguration extends WebMvcConfigurerAdapter
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties("spring.boot.admin.monitor")
public StatusUpdater statusUpdater() {
RestTemplate template = new RestTemplate();
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
......@@ -129,7 +131,9 @@ public class AdminServerWebConfiguration extends WebMvcConfigurerAdapter
return false;
}
});
return new StatusUpdater(template, applicationStore);
StatusUpdater statusUpdater = new StatusUpdater(template, applicationStore);
statusUpdater.setStatusLifetime(adminServerProperties().getMonitor().getStatusLifetime());
return statusUpdater;
}
@EventListener
......@@ -152,7 +156,7 @@ public class AdminServerWebConfiguration extends WebMvcConfigurerAdapter
public void run() {
statusUpdater().updateStatusForAllApplications();
}
}, monitorPeriod);
}, adminServerProperties().getMonitor().getPeriod());
return registrar;
}
......
......@@ -41,10 +41,6 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
private final ApplicationStore store;
private final RestTemplate restTemplate;
private ApplicationEventPublisher publisher;
/**
* Lifetime of status in ms. The status won't be updated as long the last status isn't expired.
*/
private long statusLifetime = 10_000L;
public StatusUpdater(RestTemplate restTemplate, ApplicationStore store) {
......
......@@ -14,7 +14,7 @@
"defaultValue": "spring-boot-admin-application-store"
},
{
"name": "spring.boot.admin.hazelcast.map",
"name": "spring.boot.admin.hazelcast.application-store",
"type": "java.lang.String",
"description": "Name of backing Hazelcast-List for storing the journal",
"defaultValue": "spring-boot-admin-event-store"
......@@ -30,11 +30,5 @@
"type": "java.lang.String",
"description": "management-path suffix for discovered applications",
"defaultValue": ""
},
{
"name": "spring.boot.admin.discovery.monitor.period",
"type": "long",
"description": "time interval in ms to update the status of applications with expired statusInfo",
"defaultValue": "10000"
}
]}
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