Interface ClusterManager
The cluster manager tracks all online proxy instances, aggregates global state (player counts, server lists), and provides methods for cross-proxy coordination.
Cluster State
Each proxy maintains a local view of the cluster state, updated via heartbeat messages. The state is eventually consistent - there may be brief periods where proxies have slightly different views.
Local vs. Global
- Local methods return data from this proxy instance only
- Global methods aggregate data from all proxies in the cluster
-
Method Summary
Modifier and TypeMethodDescriptionfindPlayerProxy(UUID playerUuid) Find which proxy a player is connected to.findPlayerProxyAsync(UUID playerUuid) Find which proxy a player is connected to (async).intGet the total number of players across all proxies.Get the proxy with the lowest load across all regions.getLeastLoadedProxy(String region) Get the proxy with the lowest load in a specific region.Get this proxy's unique identifier.Get information about this proxy instance.Get this proxy's region.Get all online proxies in the cluster, including this one.getProxiesInRegion(String region) Get all proxies in a specific region.Get a specific proxy by its ID.intGet the number of online proxy instances.booleanCheck if clustering is enabled and connected.booleanisPlayerOnline(UUID playerUuid) Check if a player is online anywhere in the cluster.isPlayerOnlineAsync(UUID playerUuid) Check if a player is online anywhere in the cluster (async).
-
Method Details
-
isClusterMode
boolean isClusterMode()Check if clustering is enabled and connected.- Returns:
- true if this proxy is part of an active cluster
-
getLocalProxyId
-
getLocalRegion
Get this proxy's region.- Returns:
- the configured region (e.g., "eu-west")
-
getLocalProxyInfo
Get information about this proxy instance.- Returns:
- the local proxy info
-
getOnlineProxies
Get all online proxies in the cluster, including this one.- Returns:
- an unmodifiable collection of proxy info
-
getProxy
-
getProxiesInRegion
Get all proxies in a specific region.- Parameters:
region- the region to filter by- Returns:
- proxies in that region
-
getGlobalPlayerCount
int getGlobalPlayerCount()Get the total number of players across all proxies.- Returns:
- the global player count
-
getProxyCount
int getProxyCount()Get the number of online proxy instances.- Returns:
- the count of online proxies
-
findPlayerProxy
Find which proxy a player is connected to.For async operations, prefer
findPlayerProxyAsync(UUID).- Parameters:
playerUuid- the player's UUID- Returns:
- the proxy ID, or empty if player is not online
-
findPlayerProxyAsync
Find which proxy a player is connected to (async).This is the preferred method for cross-cluster lookups as it doesn't block while waiting for Redis responses.
- Parameters:
playerUuid- the player's UUID- Returns:
- a future completing with the proxy ID, or empty if not online
-
isPlayerOnline
Check if a player is online anywhere in the cluster.For async operations, prefer
isPlayerOnlineAsync(UUID).- Parameters:
playerUuid- the player's UUID- Returns:
- true if the player is connected to any proxy
-
isPlayerOnlineAsync
Check if a player is online anywhere in the cluster (async).This is the preferred method for cross-cluster lookups as it doesn't block while waiting for Redis responses.
- Parameters:
playerUuid- the player's UUID- Returns:
- a future completing with true if the player is online
-
getLeastLoadedProxy
Get the proxy with the lowest load in a specific region.Useful for load balancing new connections within a region. Use
getLeastLoadedProxy()for any region.- Parameters:
region- the region to search (must not be null)- Returns:
- the least loaded proxy in that region, or empty if none available
-
getLeastLoadedProxy
-