Class DiscoveryHealthChecker
java.lang.Object
com.loomcache.server.discovery.DiscoveryHealthChecker
Health checker for validating discovered peer addresses.
Detects when a discovery strategy returns stale, unreachable, or incorrect addresses. Can be used to validate discovery results before using them for cluster communication.
Validation Strategy
- DNS lookup: verify the address is resolvable
- TCP connectivity check (optional): attempt to connect to the peer port
- Duplicate detection: identify duplicate addresses in the peer list
- Valid port range: verify ports are in the valid range [1, 65535]
Thread Safety
Thread-safe. All checks are non-blocking and use lightweight validations. TCP connectivity checks are performed synchronously but with timeout.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of a discovery validation check. -
Constructor Summary
ConstructorsConstructorDescriptionDiscoveryHealthChecker(String strategyName, @Nullable io.micrometer.core.instrument.MeterRegistry meterRegistry) Create a discovery health checker. -
Method Summary
Modifier and TypeMethodDescriptionvalidate(List<PeerAddress> peers, boolean checkTcpConnectivity) Validate a list of discovered peers.validateQuick(List<PeerAddress> peers) Quick validation without TCP connectivity checks.
-
Constructor Details
-
DiscoveryHealthChecker
public DiscoveryHealthChecker(String strategyName, @Nullable io.micrometer.core.instrument.MeterRegistry meterRegistry) Create a discovery health checker.- Parameters:
strategyName- name of the discovery strategy being validated (for metrics and logging)meterRegistry- optional MeterRegistry for metrics (can be null)
-
-
Method Details
-
validate
public DiscoveryHealthChecker.DiscoveryValidationResult validate(List<PeerAddress> peers, boolean checkTcpConnectivity) Validate a list of discovered peers.Performs multiple checks:
- Validates address format and port ranges
- Detects duplicate addresses
- Verifies addresses are resolvable (DNS check)
- Optionally verifies TCP connectivity in parallel
- Parameters:
peers- list of discovered peer addressescheckTcpConnectivity- if true, attempts TCP connection to each peer (may slow validation)- Returns:
- validation result containing valid peers and detected issues
-
validateQuick
Quick validation without TCP connectivity checks.- Parameters:
peers- list of discovered peer addresses- Returns:
- validation result
-