diff --git a/src/main/java/com/uid2/shared/Const.java b/src/main/java/com/uid2/shared/Const.java index c7047c34..c526a41a 100644 --- a/src/main/java/com/uid2/shared/Const.java +++ b/src/main/java/com/uid2/shared/Const.java @@ -87,7 +87,7 @@ public static class Config { // Others public static final String SaltsExpiredShutdownHours = "salts_expired_shutdown_hours"; - public static final String KeysetKeysFailedShutdownHours = "keysetkeys_failed_shutdown_hours"; + public static final String StoreRefreshStaleShutdownHours = "store_refresh_stale_shutdown_hours"; public static final String encryptionSupportVersion = "encryption_support_version"; } diff --git a/src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java b/src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java index 95e6504f..a88a6443 100644 --- a/src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java +++ b/src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java @@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import java.util.function.Consumer; public class RotatingStoreVerticle extends AbstractVerticle { private static final Logger LOGGER = LoggerFactory.getLogger(RotatingStoreVerticle.class); @@ -32,7 +31,7 @@ public class RotatingStoreVerticle extends AbstractVerticle { private final AtomicLong latestVersion = new AtomicLong(-1L); private final AtomicLong latestEntryCount = new AtomicLong(-1L); private final AtomicInteger storeRefreshIsFailing = new AtomicInteger(0); - private final Consumer refreshCallback; + private final Runnable refreshCallback; private final long refreshIntervalMs; @@ -41,7 +40,7 @@ public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadata } public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadataVersionedStore versionedStore, - Consumer refreshCallback) { + Runnable refreshCallback) { this.healthComponent = HealthManager.instance.registerComponent(storeName + "-rotator"); this.healthComponent.setHealthStatus(false, "not started"); @@ -103,6 +102,9 @@ private void startRefresh(Promise promise) { promise.complete(); storeRefreshTimer.record(java.time.Duration.ofMillis(startupRefreshTimeMs)); LOGGER.info("Successful " + this.storeName + " loading. Starting Background Refresh"); + if (this.refreshCallback != null) { + this.refreshCallback.run(); + } this.startBackgroundRefresh(); } else { this.healthComponent.setHealthStatus(false, ar.cause().getMessage()); @@ -127,15 +129,12 @@ private void startBackgroundRefresh() { this.counterStoreRefreshFailures.increment(); this.storeRefreshIsFailing.set(1); LOGGER.error("Failed to load " + this.storeName + ", " + elapsed + " ms", asyncResult.cause()); - if (this.refreshCallback != null) { - this.refreshCallback.accept(false); - } } else { this.counterStoreRefreshed.increment(); this.storeRefreshIsFailing.set(0); LOGGER.trace("Successfully refreshed " + this.storeName + ", " + elapsed + " ms"); if (this.refreshCallback != null) { - this.refreshCallback.accept(true); + this.refreshCallback.run(); } } }