Class ClusterConfigManager

java.lang.Object
com.loomcache.server.config.ClusterConfigManager

public class ClusterConfigManager extends Object
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 Details

  • Constructor Details

    • ClusterConfigManager

      public ClusterConfigManager(String nodeId)
      Create a new ClusterConfigManager.
      Parameters:
      nodeId - the ID of the current node
  • Method Details

    • get

      public Optional<String> get(String key)
      Get a configuration value.
      Parameters:
      key - the configuration key
      Returns:
      Optional containing the value if found
    • getEntry

      public Optional<ConfigEntry> getEntry(String key)
      Get a configuration entry with metadata.
      Parameters:
      key - the configuration key
      Returns:
      Optional containing the entry if found
    • set

      public void set(String key, String value)
      Set a configuration value. Validates before applying.
      Parameters:
      key - the configuration key
      value - the configuration value
      Throws:
      IllegalArgumentException - if validation fails
    • delete

      public boolean delete(String key)
      Delete a configuration entry.
      Parameters:
      key - the configuration key
      Returns:
      true if an entry was deleted, false if the key didn't exist
    • getAll

      public Map<String, ConfigEntry> getAll()
      Get all configuration entries.
      Returns:
      immutable map of all entries
    • snapshot

      public ConfigSnapshot snapshot()
      Get a snapshot of all configuration entries.
      Returns:
      ConfigSnapshot with current state
    • watch

      public void watch(String key, ConfigChangeListener listener)
      Watch for changes to a configuration key.
      Parameters:
      key - the configuration key to watch
      listener - the change listener to invoke
    • unwatch

      public void unwatch(String key, ConfigChangeListener listener)
      Unwatch a configuration key.
      Parameters:
      key - the configuration key
      listener - the listener to remove
    • getStats

      public ConfigManagerStats 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