Class TopologyChangeCacheListener

java.lang.Object
org.keycloak.connections.infinispan.shutdown.TopologyChangeCacheListener

public class TopologyChangeCacheListener extends Object
An Infinispan cache listener that delays server shutdown until the cache topology is stable (i.e. no rehash is in progress).

Use waitForStableTopology(Cache) to register this listener on a cache. It returns a WaitConditionShutdownListener that should be added to the ShutdownManager.

Limitation: when two or more Keycloak instances receive a shutdown signal simultaneously, each instance may observe a stable topology before any of them have actually left the cluster. In this scenario, all instances proceed with shutdown concurrently, increasing the risk of data loss.

  • Method Details

    • waitForStableTopology

      public static WaitConditionShutdownListener waitForStableTopology(org.infinispan.Cache<?,?> cache)
      Registers a topology change listener on the given cache and returns a WaitConditionShutdownListener that blocks shutdown while the cache topology is unstable.
      Parameters:
      cache - The cache to monitor for topology changes.
      Returns:
      A WaitConditionShutdownListener to be registered with the ShutdownManager.
    • onTopologyChange

      public void onTopologyChange(org.infinispan.notifications.cachelistener.event.TopologyChangedEvent<?,?> event)