@@ -31,10 +31,16 @@ public class RotatingStoreVerticle extends AbstractVerticle {
3131 private final AtomicLong latestVersion = new AtomicLong (-1L );
3232 private final AtomicLong latestEntryCount = new AtomicLong (-1L );
3333 private final AtomicInteger storeRefreshIsFailing = new AtomicInteger (0 );
34+ private final Runnable refreshCallback ;
3435
3536 private final long refreshIntervalMs ;
3637
3738 public RotatingStoreVerticle (String storeName , long refreshIntervalMs , IMetadataVersionedStore versionedStore ) {
39+ this (storeName , refreshIntervalMs , versionedStore , null );
40+ }
41+
42+ public RotatingStoreVerticle (String storeName , long refreshIntervalMs , IMetadataVersionedStore versionedStore ,
43+ Runnable refreshCallback ) {
3844 this .healthComponent = HealthManager .instance .registerComponent (storeName + "-rotator" );
3945 this .healthComponent .setHealthStatus (false , "not started" );
4046
@@ -72,6 +78,7 @@ public RotatingStoreVerticle(String storeName, long refreshIntervalMs, IMetadata
7278 this .versionedStore = versionedStore ;
7379 this .refreshIntervalMs = refreshIntervalMs ;
7480 this .storeRefreshTimer = Metrics .timer ("uid2_store_refresh_duration" , "store_name" , storeName );
81+ this .refreshCallback = refreshCallback ;
7582 }
7683
7784 @ Override
@@ -95,6 +102,9 @@ private void startRefresh(Promise<Void> promise) {
95102 promise .complete ();
96103 storeRefreshTimer .record (java .time .Duration .ofMillis (startupRefreshTimeMs ));
97104 LOGGER .info ("Successful " + this .storeName + " loading. Starting Background Refresh" );
105+ if (this .refreshCallback != null ) {
106+ this .refreshCallback .run ();
107+ }
98108 this .startBackgroundRefresh ();
99109 } else {
100110 this .healthComponent .setHealthStatus (false , ar .cause ().getMessage ());
@@ -123,6 +133,9 @@ private void startBackgroundRefresh() {
123133 this .counterStoreRefreshed .increment ();
124134 this .storeRefreshIsFailing .set (0 );
125135 LOGGER .trace ("Successfully refreshed " + this .storeName + ", " + elapsed + " ms" );
136+ if (this .refreshCallback != null ) {
137+ this .refreshCallback .run ();
138+ }
126139 }
127140 }
128141 );
0 commit comments