Class ClusterConfigManager
java.lang.Object
com.loomcache.server.config.ClusterConfigManager
Cluster-wide dynamic configuration management with Raft replication.
Stores configuration as distributed key-value pairs replicated via Raft. Supports watching for configuration changes and applying them without restart.
Configuration namespaces:
- "cache." - cache-related settings
- "raft." - Raft consensus settings
- "network." - network tuning parameters
- "security." - security and authentication settings
- "log." - logging configuration
All operations are thread-safe using ReentrantReadWriteLock.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all configuration entries (for testing).booleanDelete a configuration entry.Get a configuration value.getAll()Get all configuration entries.Get a configuration entry with metadata.getStats()Get current statistics.voidSet a configuration value.intsize()Get the number of configuration entries.snapshot()Get a snapshot of all configuration entries.voidunwatch(String key, ConfigChangeListener listener) Unwatch a configuration key.voidwatch(String key, ConfigChangeListener listener) Watch for changes to a configuration key.
-
Field Details
-
NAMESPACE_CACHE
- See Also:
-
NAMESPACE_RAFT
- See Also:
-
NAMESPACE_NETWORK
- See Also:
-
NAMESPACE_SECURITY
- See Also:
-
NAMESPACE_LOG
- See Also:
-
-
Constructor Details
-
ClusterConfigManager
Create a new ClusterConfigManager.- Parameters:
nodeId- the ID of the current node
-
-
Method Details
-
get
-
getEntry
Get a configuration entry with metadata.- Parameters:
key- the configuration key- Returns:
- Optional containing the entry if found
-
set
Set a configuration value. Validates before applying.- Parameters:
key- the configuration keyvalue- the configuration value- Throws:
IllegalArgumentException- if validation fails
-
delete
Delete a configuration entry.- Parameters:
key- the configuration key- Returns:
- true if an entry was deleted, false if the key didn't exist
-
getAll
Get all configuration entries.- Returns:
- immutable map of all entries
-
snapshot
Get a snapshot of all configuration entries.- Returns:
- ConfigSnapshot with current state
-
watch
Watch for changes to a configuration key.- Parameters:
key- the configuration key to watchlistener- the change listener to invoke
-
unwatch
Unwatch a configuration key.- Parameters:
key- the configuration keylistener- the listener to remove
-
getStats
Get current statistics.- Returns:
- ConfigManagerStats with operation counts
-
clear
public void clear()Clear all configuration entries (for testing). -
size
public int size()Get the number of configuration entries.- Returns:
- entry count
-