Class NodeHealthTracker
java.lang.Object
com.loomcache.client.NodeHealthTracker
Tracks node health based on success/failure rates.
Health state transitions: - HEALTHY → SUSPECTED: 3+ consecutive failures - SUSPECTED → UNHEALTHY: 10+ consecutive failures - UNHEALTHY → HEALTHY: 3+ consecutive successes
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumNode health status enum. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all health tracking data.intgetConsecutiveFailures(String nodeId) Get the number of consecutive failures for a node.intgetConsecutiveSuccesses(String nodeId) Get the number of consecutive successes for a node.longgetLastFailureTime(String nodeId) Get the timestamp of the last failure for a node.longgetLastSuccessTime(String nodeId) Get the timestamp of the last success for a node.Get the current health status of a node.longgetTotalFailures(String nodeId) Get total failures for a node.longgetTotalSuccesses(String nodeId) Get total successes for a node.booleanCheck if a node is healthy.voidrecordFailure(String nodeId) Record a failed operation for a node.voidrecordSuccess(String nodeId) Record a successful operation for a node.voidReset health state for a node.
-
Constructor Details
-
NodeHealthTracker
public NodeHealthTracker()
-
-
Method Details
-
recordSuccess
Record a successful operation for a node.- Parameters:
nodeId- the node identifier (must not be null)
-
recordFailure
Record a failed operation for a node.- Parameters:
nodeId- the node identifier (must not be null)
-
getStatus
Get the current health status of a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- the health status (defaults to HEALTHY if no data)
-
isHealthy
Check if a node is healthy.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- true if the node is HEALTHY, false otherwise
-
getConsecutiveFailures
Get the number of consecutive failures for a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- consecutive failure count
-
getConsecutiveSuccesses
Get the number of consecutive successes for a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- consecutive success count
-
getTotalFailures
Get total failures for a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- total failure count
-
getTotalSuccesses
Get total successes for a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- total success count
-
reset
Reset health state for a node.- Parameters:
nodeId- the node identifier (must not be null)
-
clear
public void clear()Clear all health tracking data. -
getLastFailureTime
Get the timestamp of the last failure for a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- last failure time in milliseconds, or 0 if no failures
-
getLastSuccessTime
Get the timestamp of the last success for a node.- Parameters:
nodeId- the node identifier (must not be null)- Returns:
- last success time in milliseconds, or 0 if no successes
-