Class CacheStartupManager
Internal caches are started serially and must all succeed before the cache manager becomes RUNNING. User caches
are submitted concurrently to the blocking executor and start in the background. The cache manager does not wait for user
caches to initialize.
- Since:
- 16.2
- Author:
- José Bolina
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExecutorServiceprotected EmbeddedCacheManagerprotected GlobalConfigurationprotected ScheduledExecutorServiceprotected TimeService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable snapshot of all tracked caches and their states.Returns the startup state of a specific cache.protected voidvoidstartInternalCaches(Set<String> names) Starts internal caches serially.startUserCaches(Set<String> names) Submits user caches for concurrent startup via the blocking executor.voidstop()Signals shutdown.
-
Field Details
-
cacheManager
-
configuration
-
timeService
-
timeoutExecutor
-
blockingExecutor
-
-
Constructor Details
-
CacheStartupManager
public CacheStartupManager()
-
-
Method Details
-
initialize
protected void initialize() -
startInternalCaches
Starts internal caches serially. Blocks until all caches are running.Failure is fatal. The exception propagates and the cache manager shuts down.
- Parameters:
names- the names of the internal caches to start. Must not benull.- Throws:
RuntimeException- if any internal cache fails to startNullPointerException- if the provided names arenull
-
startUserCaches
Submits user caches for concurrent startup via the blocking executor.Can be called multiple times and accumulate the tasks across calls. The
ProgressTrackertracks the total count and progress.If the blocking executor thread pool is too small for concurrent startup, caches are started serially to avoid potential deadlock. Cache components submit nested blocking work during
cache.start(), so the pool must have enough threads for both the cache start tasks and the nested work.- Parameters:
names- the names of the user caches to start. Must not benull.- Throws:
NullPointerException- In case the provided names arenull.
-
getState
Returns the startup state of a specific cache.- Parameters:
name- the cache name to query. Must not benull.- Returns:
- the current
CacheStartupState, ornullif the cache is not tracked by this manager
-
getAllStates
Returns an unmodifiable snapshot of all tracked caches and their states.- Returns:
- a map from cache name to
CacheStartupState. Nevernull.
-
stop
public void stop()Signals shutdown.Prevents new cache submissions and causes pending tasks to complete with
CacheStartupState.FAILED.
-