Adds dynamic timespan

This commit is contained in:
Julien Lengrand-Lambert
2020-11-15 17:04:59 +01:00
parent 28bcf9cf77
commit 6ab9bbf591
2 changed files with 6 additions and 3 deletions

View File

@@ -14,13 +14,15 @@ import java.util.concurrent.TimeUnit;
@ApplicationScoped
public class CellarMonitor {
private ScheduledFuture monitorHandle;
private static final int THREADS = 1;
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(THREADS);
private static final long START = 0;
private static final long SPAN = 30;
private ScheduledFuture monitorHandle;
@ConfigProperty(name = "monitor.time.span", defaultValue = "15")
private long span;
@Inject
private TimeUnit timeUnit;
@@ -34,7 +36,7 @@ public class CellarMonitor {
final Runnable monitoring = () -> { sensorApi.add(dataDriver.getSensorValues()); };
public void startMonitoring(){
monitorHandle = scheduler.scheduleAtFixedRate(monitoring, START, SPAN, timeUnit);
monitorHandle = scheduler.scheduleAtFixedRate(monitoring, START, span, timeUnit);
}
public void stopMonitoring(){

View File

@@ -21,6 +21,7 @@ monitoring.enabled=true
driver.type=dummy
sensor.api.type=influx
monitor.time.unit=MINUTES
monitor.time.span=30
# Microprofile server properties
server.port=8080