Class VersionCompatibilityManager
Responsibilities: 1. Determine compatibility between local and remote versions 2. Track compatible versions (same major version, within min/max bounds) 3. Resolve available features based on negotiated version 4. Support rolling upgrades with feature-aware messaging
Thread-safe: Uses ConcurrentHashMap for per-peer version tracking.
-
Constructor Summary
ConstructorsConstructorDescriptionVersionCompatibilityManager(LoomVersion localVersion) Create a version compatibility manager. -
Method Summary
Modifier and TypeMethodDescriptionGet all registered peer versions.static VersionCompatibilityManagerCreate a manager with the current build version.getCompatibleFeatures(LoomVersion negotiatedVersion) Get features available given a negotiated version.getCompatibleFeaturesForPeer(String peerId) Get features available for communication with a specific peer.@Nullable LoomVersiongetPeerVersion(String peerId) Get the registered version for a peer.booleanhasFeature(LoomVersion version, Feature feature) Check if a feature is available for a given version.booleanhasFeatureForPeer(String peerId, Feature feature) Check if a feature is available for communication with a specific peer.booleanisCompatible(LoomVersion remoteVersion) Check if a remote version is compatible with the local version.Get the local node's version.voidregisterPeerVersion(String peerId, LoomVersion version) Register a peer's version after successful handshake.
-
Constructor Details
-
VersionCompatibilityManager
Create a version compatibility manager.- Parameters:
localVersion- the local node's version (must not be null)- Throws:
IllegalArgumentException- if localVersion is null
-
-
Method Details
-
forCurrentVersion
Create a manager with the current build version.- Returns:
- a new VersionCompatibilityManager
-
localVersion
-
isCompatible
Check if a remote version is compatible with the local version.Compatibility rules: 1. Major versions must be equal (major version is a breaking change boundary) 2. Remote version must be >= minimum compatible version
- Parameters:
remoteVersion- the version to check (must not be null)- Returns:
- true if compatible, false otherwise
- Throws:
IllegalArgumentException- if remoteVersion is null
-
registerPeerVersion
Register a peer's version after successful handshake.This allows the manager to track which versions are present in the cluster and enables version-aware feature negotiation.
- Parameters:
peerId- the peer's unique identifier (must not be null or blank)version- the peer's version (must not be null)- Throws:
IllegalArgumentException- if peerId is null/blank or version is null
-
getPeerVersion
Get the registered version for a peer.- Parameters:
peerId- the peer's identifier (must not be null or blank)- Returns:
- the peer's version, or null if not registered
- Throws:
IllegalArgumentException- if peerId is null or blank
-
getCompatibleFeatures
Get features available given a negotiated version.A feature is available if the negotiated version is >= the version in which the feature was introduced (and same major version).
- Parameters:
negotiatedVersion- the version to check features for (must not be null)- Returns:
- an immutable set of available features
- Throws:
IllegalArgumentException- if negotiatedVersion is null
-
getCompatibleFeaturesForPeer
Get features available for communication with a specific peer.Uses the minimum of local and peer versions to determine compatibility.
- Parameters:
peerId- the peer's identifier (must not be null or blank)- Returns:
- an immutable set of features available for this peer, or empty set if peer not registered
- Throws:
IllegalArgumentException- if peerId is null or blank
-
allPeerVersions
Get all registered peer versions.Useful for cluster introspection and rolling upgrade monitoring.
- Returns:
- an immutable copy of the peer versions map
-
hasFeature
Check if a feature is available for a given version.- Parameters:
version- the version to check (must not be null)feature- the feature to check (must not be null)- Returns:
- true if the feature is available in the given version, false otherwise
- Throws:
IllegalArgumentException- if version or feature is null
-
hasFeatureForPeer
Check if a feature is available for communication with a specific peer.- Parameters:
peerId- the peer's identifier (must not be null or blank)feature- the feature to check (must not be null)- Returns:
- true if the feature is available for this peer, false otherwise
- Throws:
IllegalArgumentException- if peerId is null/blank or feature is null
-