diff --git a/src/main/java/com/uid2/shared/Const.java b/src/main/java/com/uid2/shared/Const.java index e9d6bd48..0f6fe4cc 100644 --- a/src/main/java/com/uid2/shared/Const.java +++ b/src/main/java/com/uid2/shared/Const.java @@ -91,6 +91,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 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 b71ad9f6..95e6504f 100644 --- a/src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java +++ b/src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java @@ -15,6 +15,7 @@ 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); @@ -31,10 +32,16 @@ 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 long refreshIntervalMs; public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadataVersionedStore versionedStore) { + this(storeName, refreshIntervalMs, versionedStore, null); + } + + public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadataVersionedStore versionedStore, + Consumer refreshCallback) { this.healthComponent = HealthManager.instance.registerComponent(storeName + "-rotator"); this.healthComponent.setHealthStatus(false, "not started"); @@ -72,6 +79,7 @@ public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadata this.versionedStore = versionedStore; this.refreshIntervalMs = refreshIntervalMs; this.storeRefreshTimer = Metrics.timer("uid2_store_refresh_duration", "store_name", storeName); + this.refreshCallback = refreshCallback; } @Override @@ -119,10 +127,16 @@ 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); + } } } );