Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/uid2/shared/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/uid2/shared/vertx/RotatingStoreVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<Boolean> 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<Boolean> refreshCallback) {
this.healthComponent = HealthManager.instance.registerComponent(storeName + "-rotator");
this.healthComponent.setHealthStatus(false, "not started");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}
);
Expand Down
Loading