public class CacheMonitor extends AbstractMonitor
Implements a three-state machine (HEALTHY → SUSPECT → DEGRADED) with proactive health checks that only run when clusters are in SUSPECT or DEGRADED states.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
CacheMonitor.ErrorCategory |
protected static class |
CacheMonitor.HealthState
Enum representing the health state of a cache cluster or endpoint.
|
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
CACHE_HEALTH_CHECK_IN_HEALTHY_STATE |
static AwsWrapperProperty |
CACHE_IN_FLIGHT_WRITE_SIZE_LIMIT |
lastActivityTimestampNanos, monitorExecutor, state, stop, terminationTimeoutSec| Modifier | Constructor and Description |
|---|---|
protected |
CacheMonitor(long inFlightWriteSizeLimitBytes,
boolean healthCheckInHealthyState,
TelemetryFactory telemetryFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
decrementInFlightSizeStatic(java.lang.String rwEndpoint,
java.lang.String roEndpoint,
long bytes) |
protected static CacheMonitor.HealthState |
getClusterState(java.lang.String rwEndpoint,
java.lang.String roEndpoint) |
protected static void |
incrementInFlightSizeStatic(java.lang.String rwEndpoint,
java.lang.String roEndpoint,
long bytes) |
void |
monitor()
Executes the monitoring loop for this monitor.
|
protected static void |
registerCluster(FullServicesContainer servicesContainer,
long inFlightWriteSizeLimitBytes,
boolean healthCheckInHealthyState,
TelemetryFactory telemetryFactory,
java.lang.String rwEndpoint,
java.lang.String roEndpoint,
boolean useSSL,
java.time.Duration cacheConnectionTimeout,
boolean iamAuthEnabled,
java.lang.String cacheIamRegion,
java.lang.String cacheName,
java.lang.String cacheUsername,
java.lang.String cachePassword) |
protected static void |
registerCluster(FullServicesContainer servicesContainer,
long inFlightWriteSizeLimitBytes,
boolean healthCheckInHealthyState,
TelemetryFactory telemetryFactory,
java.lang.String rwEndpoint,
java.lang.String roEndpoint,
boolean useSSL,
java.time.Duration cacheConnectionTimeout,
boolean iamAuthEnabled,
java.lang.String cacheIamRegion,
java.lang.String cacheName,
java.lang.String cacheUsername,
java.lang.String cachePassword,
boolean createPingConnection,
boolean startMonitorThread) |
protected static void |
reportError(java.lang.String rwEndpoint,
java.lang.String roEndpoint,
boolean isRw,
java.lang.Throwable error,
java.lang.String operation) |
protected static void |
resetInstance() |
protected void |
setPingConnections(software.amazon.jdbc.plugin.cache.CacheMonitor.ClusterHealthState cluster,
CachePingConnection rwConnection,
CachePingConnection roConnection) |
protected void |
sleep(long duration) |
canDispose, close, getLastActivityTimestampNanos, getState, run, start, stoppublic static final AwsWrapperProperty CACHE_IN_FLIGHT_WRITE_SIZE_LIMIT
public static final AwsWrapperProperty CACHE_HEALTH_CHECK_IN_HEALTHY_STATE
protected CacheMonitor(long inFlightWriteSizeLimitBytes,
boolean healthCheckInHealthyState,
TelemetryFactory telemetryFactory)
protected static void registerCluster(FullServicesContainer servicesContainer, long inFlightWriteSizeLimitBytes, boolean healthCheckInHealthyState, TelemetryFactory telemetryFactory, java.lang.String rwEndpoint, java.lang.String roEndpoint, boolean useSSL, java.time.Duration cacheConnectionTimeout, boolean iamAuthEnabled, java.lang.String cacheIamRegion, java.lang.String cacheName, java.lang.String cacheUsername, java.lang.String cachePassword, boolean createPingConnection, boolean startMonitorThread)
protected static void registerCluster(FullServicesContainer servicesContainer, long inFlightWriteSizeLimitBytes, boolean healthCheckInHealthyState, TelemetryFactory telemetryFactory, java.lang.String rwEndpoint, java.lang.String roEndpoint, boolean useSSL, java.time.Duration cacheConnectionTimeout, boolean iamAuthEnabled, java.lang.String cacheIamRegion, java.lang.String cacheName, java.lang.String cacheUsername, java.lang.String cachePassword)
protected void setPingConnections(software.amazon.jdbc.plugin.cache.CacheMonitor.ClusterHealthState cluster,
CachePingConnection rwConnection,
CachePingConnection roConnection)
protected static CacheMonitor.HealthState getClusterState(java.lang.String rwEndpoint, java.lang.String roEndpoint)
protected static void reportError(java.lang.String rwEndpoint,
java.lang.String roEndpoint,
boolean isRw,
java.lang.Throwable error,
java.lang.String operation)
protected static void incrementInFlightSizeStatic(java.lang.String rwEndpoint,
java.lang.String roEndpoint,
long bytes)
protected static void decrementInFlightSizeStatic(java.lang.String rwEndpoint,
java.lang.String roEndpoint,
long bytes)
public void monitor()
throws java.lang.Exception
MonitorMonitor.start(). Additionally, the monitoring loop should regularly update the last
activity timestamp so that the MonitorService can detect whether the monitor is stuck or not.java.lang.Exception - if there's an error executing the monitoring logic.protected void sleep(long duration)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected static void resetInstance()