From 9cc7702b81d0b5436c343a2acda7147b37c7425f Mon Sep 17 00:00:00 2001 From: ulrichschulte Date: Fri, 17 Nov 2023 08:44:24 +0100 Subject: [PATCH 1/7] #2897: WIP Fix exponential backoff --- .../server/config/AdminServerAutoConfiguration.java | 2 ++ .../admin/server/config/AdminServerProperties.java | 12 ++++++++++++ .../admin/server/services/InfoUpdateTrigger.java | 5 ++++- .../boot/admin/server/services/IntervalCheck.java | 8 ++++++-- .../admin/server/services/StatusUpdateTrigger.java | 4 ++++ .../admin/server/services/IntervalCheckTest.java | 2 +- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java index 849832ab315..34e24d95866 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java @@ -98,6 +98,7 @@ public StatusUpdateTrigger statusUpdateTrigger(StatusUpdater statusUpdater, Publ StatusUpdateTrigger trigger = new StatusUpdateTrigger(statusUpdater, events); trigger.setInterval(this.adminServerProperties.getMonitor().getStatusInterval()); trigger.setLifetime(this.adminServerProperties.getMonitor().getStatusLifetime()); + trigger.setMaxBackoff(this.adminServerProperties.getMonitor().getStatusMaxBackoff()); return trigger; } @@ -132,6 +133,7 @@ public InfoUpdateTrigger infoUpdateTrigger(InfoUpdater infoUpdater, Publisher { public InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher publisher) { super(publisher, InstanceEvent.class); this.infoUpdater = infoUpdater; - this.intervalCheck = new IntervalCheck("info", this::updateInfo, Duration.ofMinutes(5), Duration.ofMinutes(1)); + this.intervalCheck = new IntervalCheck("info", this::updateInfo, Duration.ofMinutes(5), Duration.ofMinutes(1), Duration.ofMinutes(10)); } @Override @@ -79,4 +79,7 @@ public void setLifetime(Duration infoLifetime) { this.intervalCheck.setMinRetention(infoLifetime); } + public void setMaxBackoff(Duration maxBackoff) { + this.intervalCheck.setMaxBackoff(maxBackoff); + } } diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java index 22bb803b52f..2343c0eac88 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java @@ -52,6 +52,9 @@ public class IntervalCheck { private final Function> checkFn; + @Setter + private Duration maxBackoff; + @Getter @Setter private Duration interval; @@ -66,15 +69,16 @@ public class IntervalCheck { private Scheduler scheduler; public IntervalCheck(String name, Function> checkFn) { - this(name, checkFn, Duration.ofSeconds(10), Duration.ofSeconds(10)); + this(name, checkFn, Duration.ofSeconds(10), Duration.ofSeconds(10), Duration.ofSeconds(60)); } public IntervalCheck(String name, Function> checkFn, Duration interval, - Duration minRetention) { + Duration minRetention, Duration maxBackoff) { this.name = name; this.checkFn = checkFn; this.interval = interval; this.minRetention = minRetention; + this.maxBackoff = maxBackoff; } public void start() { diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java index 9d66bfeb0e2..446886c257d 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java @@ -81,4 +81,8 @@ public void setLifetime(Duration statusLifetime) { this.intervalCheck.setMinRetention(statusLifetime); } + public void setMaxBackoff(Duration maxBackoff) { + this.intervalCheck.setMaxBackoff(maxBackoff); + } + } diff --git a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java index 4830c5aa9e0..810ff8a8528 100644 --- a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java +++ b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java @@ -41,7 +41,7 @@ public class IntervalCheckTest { private final Function> checkFn = mock(Function.class, (i) -> Mono.empty()); private final IntervalCheck intervalCheck = new IntervalCheck("test", this.checkFn, Duration.ofMillis(10), - Duration.ofMillis(10)); + Duration.ofMillis(10), Duration.ofMinutes(60)); @Test public void should_check_after_being_started() throws InterruptedException { From f334a321b8b8b2d6a678006927bcc2eb30d1f38c Mon Sep 17 00:00:00 2001 From: "erik.petzold" Date: Fri, 17 Nov 2023 08:53:42 +0100 Subject: [PATCH 2/7] reduce number of places where defaults can be defined --- .../codecentric/boot/admin/server/services/IntervalCheck.java | 4 ---- .../boot/admin/server/services/StatusUpdateTrigger.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java index 2343c0eac88..4bb1850e0a5 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java @@ -68,10 +68,6 @@ public class IntervalCheck { @Nullable private Scheduler scheduler; - public IntervalCheck(String name, Function> checkFn) { - this(name, checkFn, Duration.ofSeconds(10), Duration.ofSeconds(10), Duration.ofSeconds(60)); - } - public IntervalCheck(String name, Function> checkFn, Duration interval, Duration minRetention, Duration maxBackoff) { this.name = name; diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java index 446886c257d..6f78ee93e1d 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java @@ -40,7 +40,7 @@ public class StatusUpdateTrigger extends AbstractEventHandler { public StatusUpdateTrigger(StatusUpdater statusUpdater, Publisher publisher) { super(publisher, InstanceEvent.class); this.statusUpdater = statusUpdater; - this.intervalCheck = new IntervalCheck("status", this::updateStatus); + this.intervalCheck = new IntervalCheck("status", this::updateStatus, Duration.ofSeconds(10), Duration.ofSeconds(10), Duration.ofSeconds(60)); } @Override From e3e834b27b96f32523d633bd3b0e4cbb486a5690 Mon Sep 17 00:00:00 2001 From: "erik.petzold" Date: Fri, 17 Nov 2023 08:56:41 +0100 Subject: [PATCH 3/7] use configured backoff in retry --- .../de/codecentric/boot/admin/server/services/IntervalCheck.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java index 4bb1850e0a5..9f982e13fcf 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/IntervalCheck.java @@ -85,6 +85,7 @@ public void start() { .subscribeOn(this.scheduler) .concatMap((i) -> this.checkAllInstances()) .retryWhen(Retry.backoff(Long.MAX_VALUE, Duration.ofSeconds(1)) + .maxBackoff(maxBackoff) .doBeforeRetry((s) -> log.warn("Unexpected error in {}-check", this.name, s.failure()))) .subscribe(null, (error) -> log.error("Unexpected error in {}-check", name, error)); } From 75a2365c53cb6caf2042666bb25f92e1d0700036 Mon Sep 17 00:00:00 2001 From: ulrichschulte Date: Fri, 17 Nov 2023 09:00:15 +0100 Subject: [PATCH 4/7] #2897: javaformat --- .../boot/admin/server/services/InfoUpdateTrigger.java | 4 +++- .../boot/admin/server/services/StatusUpdateTrigger.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java index ded3738407f..cf1873cf1cc 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java @@ -41,7 +41,8 @@ public class InfoUpdateTrigger extends AbstractEventHandler { public InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher publisher) { super(publisher, InstanceEvent.class); this.infoUpdater = infoUpdater; - this.intervalCheck = new IntervalCheck("info", this::updateInfo, Duration.ofMinutes(5), Duration.ofMinutes(1), Duration.ofMinutes(10)); + this.intervalCheck = new IntervalCheck("info", this::updateInfo, Duration.ofMinutes(5), Duration.ofMinutes(1), + Duration.ofMinutes(10)); } @Override @@ -82,4 +83,5 @@ public void setLifetime(Duration infoLifetime) { public void setMaxBackoff(Duration maxBackoff) { this.intervalCheck.setMaxBackoff(maxBackoff); } + } diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java index 6f78ee93e1d..9cb3dd6f6f0 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java @@ -40,7 +40,8 @@ public class StatusUpdateTrigger extends AbstractEventHandler { public StatusUpdateTrigger(StatusUpdater statusUpdater, Publisher publisher) { super(publisher, InstanceEvent.class); this.statusUpdater = statusUpdater; - this.intervalCheck = new IntervalCheck("status", this::updateStatus, Duration.ofSeconds(10), Duration.ofSeconds(10), Duration.ofSeconds(60)); + this.intervalCheck = new IntervalCheck("status", this::updateStatus, Duration.ofSeconds(10), + Duration.ofSeconds(10), Duration.ofSeconds(60)); } @Override From a129416352560aa49c59a6b21bc032934b30e927 Mon Sep 17 00:00:00 2001 From: "erik.petzold" Date: Fri, 17 Nov 2023 09:38:52 +0100 Subject: [PATCH 5/7] add Test --- .../admin/server/services/IntervalCheckTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java index 810ff8a8528..5832ee47c1c 100644 --- a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java +++ b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/IntervalCheckTest.java @@ -41,7 +41,7 @@ public class IntervalCheckTest { private final Function> checkFn = mock(Function.class, (i) -> Mono.empty()); private final IntervalCheck intervalCheck = new IntervalCheck("test", this.checkFn, Duration.ofMillis(10), - Duration.ofMillis(10), Duration.ofMinutes(60)); + Duration.ofMillis(10), Duration.ofSeconds(1)); @Test public void should_check_after_being_started() throws InterruptedException { @@ -81,6 +81,20 @@ public void should_recheck_after_retention_period() throws InterruptedException verify(this.checkFn, atLeast(2)).apply(INSTANCE_ID); } + @Test + public void should_not_wait_longer_than_maxBackoff() throws InterruptedException { + this.intervalCheck.setInterval(Duration.ofMillis(10)); + this.intervalCheck.setMinRetention(Duration.ofMillis(10)); + this.intervalCheck.setMaxBackoff(Duration.ofSeconds(2)); + this.intervalCheck.markAsChecked(INSTANCE_ID); + + when(this.checkFn.apply(any())).thenReturn(Mono.error(new RuntimeException("Test"))); + + this.intervalCheck.start(); + Thread.sleep(1000 * 10); + verify(this.checkFn, atLeast(7)).apply(INSTANCE_ID); + } + @Test public void should_check_after_error() throws InterruptedException { this.intervalCheck.markAsChecked(INSTANCE_ID); From d2c7ddc078814b1440b94080a66fb542f4f5f16f Mon Sep 17 00:00:00 2001 From: "erik.petzold" Date: Fri, 17 Nov 2023 09:53:20 +0100 Subject: [PATCH 6/7] add docs --- spring-boot-admin-docs/src/site/asciidoc/server.adoc | 8 ++++++++ .../boot/admin/server/config/AdminServerProperties.java | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/spring-boot-admin-docs/src/site/asciidoc/server.adoc b/spring-boot-admin-docs/src/site/asciidoc/server.adoc index 42ef3b90918..7bbd278d6b7 100644 --- a/spring-boot-admin-docs/src/site/asciidoc/server.adoc +++ b/spring-boot-admin-docs/src/site/asciidoc/server.adoc @@ -22,6 +22,10 @@ In addition when the reverse proxy terminates the https connection, it may be ne | Time interval to check the status of instances. | 10,000ms +| spring.boot.admin.monitor.status-max-backoff +| The maximal backoff for status check retries (retry after error has exponential backoff, minimum backoff is 1 second). +| 60,000ms + | spring.boot.admin.monitor.status-lifetime | Lifetime of status. The status won't be updated as long the last status isn't expired. | 10,000ms @@ -30,6 +34,10 @@ In addition when the reverse proxy terminates the https connection, it may be ne | Time interval to check the info of instances. | 1m +| spring.boot.admin.monitor.info-max-backoff +| The maximal backoff for info check retries (retry after error has exponential backoff, minimum backoff is 1 second). +| 10m + | spring.boot.admin.monitor.info-lifetime | Lifetime of info. The info won't be updated as long the last info isn't expired. | 1m diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java index 3c3fb8ebba7..28e735cbbe4 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java @@ -104,10 +104,10 @@ public static class MonitorProperties { private Duration statusLifetime = Duration.ofMillis(10_000L); /** - * Time interval representing the maximal backoff for status check retries. + * The maximal backoff for status check retries (retry after error has exponential backoff, minimum backoff is 1 second). */ @DurationUnit(ChronoUnit.MILLIS) - private Duration statusMaxBackoff = Duration.ofMillis(10_000L); + private Duration statusMaxBackoff = Duration.ofMillis(60_000L); /** * Time interval to check the info of instances, @@ -116,10 +116,10 @@ public static class MonitorProperties { private Duration infoInterval = Duration.ofMinutes(1L); /** - * Time interval representing the maximal backoff for info check retries. + * The maximal backoff for info check retries (retry after error has exponential backoff, minimum backoff is 1 second). */ @DurationUnit(ChronoUnit.MILLIS) - private Duration infoMaxBackoff = Duration.ofMinutes(1L); + private Duration infoMaxBackoff = Duration.ofMinutes(10); /** * Lifetime of info. The info won't be updated as long the last info isn't From 56438c52e9d5f6ec3d0c0c0817076ba22b7191df Mon Sep 17 00:00:00 2001 From: "erik.petzold" Date: Fri, 17 Nov 2023 11:13:57 +0100 Subject: [PATCH 7/7] reduce number of places with defaults --- .../config/AdminServerAutoConfiguration.java | 17 +++++++---------- .../server/config/AdminServerProperties.java | 6 ++++-- .../server/services/InfoUpdateTrigger.java | 10 +++------- .../server/services/StatusUpdateTrigger.java | 11 ++++------- .../server/services/InfoUpdateTriggerTest.java | 3 ++- .../services/StatusUpdateTriggerTest.java | 3 ++- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java index 34e24d95866..406d24e3b37 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java @@ -95,11 +95,10 @@ public StatusUpdater statusUpdater(InstanceRepository instanceRepository, @Bean(initMethod = "start", destroyMethod = "stop") @ConditionalOnMissingBean public StatusUpdateTrigger statusUpdateTrigger(StatusUpdater statusUpdater, Publisher events) { - StatusUpdateTrigger trigger = new StatusUpdateTrigger(statusUpdater, events); - trigger.setInterval(this.adminServerProperties.getMonitor().getStatusInterval()); - trigger.setLifetime(this.adminServerProperties.getMonitor().getStatusLifetime()); - trigger.setMaxBackoff(this.adminServerProperties.getMonitor().getStatusMaxBackoff()); - return trigger; + return new StatusUpdateTrigger(statusUpdater, events, + this.adminServerProperties.getMonitor().getStatusInterval(), + this.adminServerProperties.getMonitor().getStatusLifetime(), + this.adminServerProperties.getMonitor().getStatusMaxBackoff()); } @Bean @@ -130,11 +129,9 @@ public InfoUpdater infoUpdater(InstanceRepository instanceRepository, @Bean(initMethod = "start", destroyMethod = "stop") @ConditionalOnMissingBean public InfoUpdateTrigger infoUpdateTrigger(InfoUpdater infoUpdater, Publisher events) { - InfoUpdateTrigger trigger = new InfoUpdateTrigger(infoUpdater, events); - trigger.setInterval(this.adminServerProperties.getMonitor().getInfoInterval()); - trigger.setLifetime(this.adminServerProperties.getMonitor().getInfoLifetime()); - trigger.setMaxBackoff(this.adminServerProperties.getMonitor().getInfoMaxBackoff()); - return trigger; + return new InfoUpdateTrigger(infoUpdater, events, this.adminServerProperties.getMonitor().getInfoInterval(), + this.adminServerProperties.getMonitor().getInfoLifetime(), + this.adminServerProperties.getMonitor().getInfoMaxBackoff()); } @Bean diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java index 28e735cbbe4..7fcf13442b9 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerProperties.java @@ -104,7 +104,8 @@ public static class MonitorProperties { private Duration statusLifetime = Duration.ofMillis(10_000L); /** - * The maximal backoff for status check retries (retry after error has exponential backoff, minimum backoff is 1 second). + * The maximal backoff for status check retries (retry after error has exponential + * backoff, minimum backoff is 1 second). */ @DurationUnit(ChronoUnit.MILLIS) private Duration statusMaxBackoff = Duration.ofMillis(60_000L); @@ -116,7 +117,8 @@ public static class MonitorProperties { private Duration infoInterval = Duration.ofMinutes(1L); /** - * The maximal backoff for info check retries (retry after error has exponential backoff, minimum backoff is 1 second). + * The maximal backoff for info check retries (retry after error has exponential + * backoff, minimum backoff is 1 second). */ @DurationUnit(ChronoUnit.MILLIS) private Duration infoMaxBackoff = Duration.ofMinutes(10); diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java index cf1873cf1cc..fa7ce27b166 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/InfoUpdateTrigger.java @@ -38,11 +38,11 @@ public class InfoUpdateTrigger extends AbstractEventHandler { private final IntervalCheck intervalCheck; - public InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher publisher) { + public InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher publisher, Duration updateInterval, + Duration infoLifetime, Duration maxBackoff) { super(publisher, InstanceEvent.class); this.infoUpdater = infoUpdater; - this.intervalCheck = new IntervalCheck("info", this::updateInfo, Duration.ofMinutes(5), Duration.ofMinutes(1), - Duration.ofMinutes(10)); + this.intervalCheck = new IntervalCheck("info", this::updateInfo, updateInterval, infoLifetime, maxBackoff); } @Override @@ -80,8 +80,4 @@ public void setLifetime(Duration infoLifetime) { this.intervalCheck.setMinRetention(infoLifetime); } - public void setMaxBackoff(Duration maxBackoff) { - this.intervalCheck.setMaxBackoff(maxBackoff); - } - } diff --git a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java index 9cb3dd6f6f0..80470f96957 100644 --- a/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java +++ b/spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/services/StatusUpdateTrigger.java @@ -37,11 +37,12 @@ public class StatusUpdateTrigger extends AbstractEventHandler { private final IntervalCheck intervalCheck; - public StatusUpdateTrigger(StatusUpdater statusUpdater, Publisher publisher) { + public StatusUpdateTrigger(StatusUpdater statusUpdater, Publisher publisher, Duration updateInterval, + Duration statusLifetime, Duration maxBackoff) { super(publisher, InstanceEvent.class); this.statusUpdater = statusUpdater; - this.intervalCheck = new IntervalCheck("status", this::updateStatus, Duration.ofSeconds(10), - Duration.ofSeconds(10), Duration.ofSeconds(60)); + this.intervalCheck = new IntervalCheck("status", this::updateStatus, updateInterval, statusLifetime, + maxBackoff); } @Override @@ -82,8 +83,4 @@ public void setLifetime(Duration statusLifetime) { this.intervalCheck.setMinRetention(statusLifetime); } - public void setMaxBackoff(Duration maxBackoff) { - this.intervalCheck.setMaxBackoff(maxBackoff); - } - } diff --git a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/InfoUpdateTriggerTest.java b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/InfoUpdateTriggerTest.java index 35aef65d99c..597ae00c32c 100644 --- a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/InfoUpdateTriggerTest.java +++ b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/InfoUpdateTriggerTest.java @@ -60,7 +60,8 @@ public class InfoUpdateTriggerTest { public void setUp() throws Exception { when(this.updater.updateInfo(any(InstanceId.class))).thenReturn(Mono.empty()); - this.trigger = new InfoUpdateTrigger(this.updater, this.events.flux()); + this.trigger = new InfoUpdateTrigger(this.updater, this.events.flux(), Duration.ofMinutes(5), Duration.ofMinutes(1), + Duration.ofMinutes(10)); this.trigger.start(); await().until(this.events::wasSubscribed); } diff --git a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/StatusUpdateTriggerTest.java b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/StatusUpdateTriggerTest.java index 88c44a5d152..de143d06776 100644 --- a/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/StatusUpdateTriggerTest.java +++ b/spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/StatusUpdateTriggerTest.java @@ -58,7 +58,8 @@ public void setUp() throws Exception { when(this.updater.updateStatus(any(InstanceId.class))).thenReturn(Mono.empty()); when(this.updater.timeout(any())).thenReturn(this.updater); - this.trigger = new StatusUpdateTrigger(this.updater, this.events.flux()); + this.trigger = new StatusUpdateTrigger(this.updater, this.events.flux(), Duration.ofSeconds(10), + Duration.ofSeconds(10), Duration.ofSeconds(60)); this.trigger.start(); await().until(this.events::wasSubscribed); }