Skip to content
Merged
2 changes: 1 addition & 1 deletion src/main/java/com/uid2/shared/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<Boolean> refreshCallback;
private final Runnable refreshCallback;

private final long refreshIntervalMs;

Expand All @@ -41,7 +40,7 @@ public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadata
}

public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadataVersionedStore versionedStore,
Consumer<Boolean> refreshCallback) {
Runnable refreshCallback) {
this.healthComponent = HealthManager.instance.registerComponent(storeName + "-rotator");
this.healthComponent.setHealthStatus(false, "not started");

Expand Down Expand Up @@ -103,6 +102,9 @@ private void startRefresh(Promise<Void> 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());
Expand All @@ -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();
}
}
}
Expand Down
Loading