public class CustomEndpointMonitorImpl extends AbstractMonitor implements CustomEndpointMonitor, StateSnapshotProvider
| Modifier and Type | Field and Description |
|---|---|
protected static long |
CUSTOM_ENDPOINT_INFO_EXPIRATION_NANO |
protected HostSpec |
customEndpointHostSpec |
protected static CacheMap<java.lang.String,CustomEndpointInfo> |
customEndpointInfoCache |
protected java.lang.String |
endpointIdentifier |
protected java.util.concurrent.atomic.AtomicBoolean |
hasConnectionIssue |
protected long |
maxRefreshRateNano |
protected long |
minRefreshRateNano |
protected static long |
MONITOR_TERMINATION_TIMEOUT_SEC |
protected software.amazon.awssdk.services.rds.RdsClient |
rdsClient |
protected int |
refreshRateBackoffFactor |
protected long |
refreshRateNano |
protected java.util.concurrent.atomic.AtomicBoolean |
refreshRequired |
protected software.amazon.awssdk.regions.Region |
region |
protected StorageService |
storageService |
protected static long |
UNAUTHORIZED_SLEEP_NANO |
lastActivityTimestampNanos, monitorExecutor, state, stop, terminationTimeoutSec| Constructor and Description |
|---|
CustomEndpointMonitorImpl(StorageService storageService,
TelemetryFactory telemetryFactory,
HostSpec customEndpointHostSpec,
java.lang.String endpointIdentifier,
software.amazon.awssdk.regions.Region region,
long refreshRateNano,
int refreshRateBackoffFactor,
long maxRefreshRateNano,
java.util.function.BiFunction<HostSpec,software.amazon.awssdk.regions.Region,software.amazon.awssdk.services.rds.RdsClient> rdsClientFunc)
Constructs a CustomEndpointMonitorImpl instance for the host specified by
customEndpointHostSpec. |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearCache()
Clears the shared custom endpoint information cache.
|
void |
close()
Closes all resources used by this monitor.
|
java.util.List<Pair<java.lang.String,java.lang.Object>> |
getSnapshotState() |
boolean |
hasCustomEndpointInfo()
Indicates whether the monitor has info about the custom endpoint or not.
|
void |
monitor()
Analyzes a given custom endpoint for changes to custom endpoint information.
|
void |
requestCustomEndpointInfoUpdate() |
protected void |
sleep(long durationNano) |
protected void |
sleepIgnoringRefreshRequests(long durationNano)
Sleeps for the given duration without being woken early by connection-driven refresh requests (see
refreshRequired). |
protected void |
slowdownRefreshRate() |
protected void |
speedupRefreshRate() |
canDispose, getLastActivityTimestampNanos, getState, run, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanDispose, getLastActivityTimestampNanos, getState, start, stopprotected static final CacheMap<java.lang.String,CustomEndpointInfo> customEndpointInfoCache
protected static final long CUSTOM_ENDPOINT_INFO_EXPIRATION_NANO
protected static final long UNAUTHORIZED_SLEEP_NANO
protected static final long MONITOR_TERMINATION_TIMEOUT_SEC
protected final java.util.concurrent.atomic.AtomicBoolean refreshRequired
protected final java.util.concurrent.atomic.AtomicBoolean hasConnectionIssue
protected final software.amazon.awssdk.services.rds.RdsClient rdsClient
protected final HostSpec customEndpointHostSpec
protected final java.lang.String endpointIdentifier
protected final software.amazon.awssdk.regions.Region region
protected long minRefreshRateNano
protected long maxRefreshRateNano
protected long refreshRateNano
protected int refreshRateBackoffFactor
protected final StorageService storageService
public CustomEndpointMonitorImpl(StorageService storageService, TelemetryFactory telemetryFactory, HostSpec customEndpointHostSpec, java.lang.String endpointIdentifier, software.amazon.awssdk.regions.Region region, long refreshRateNano, int refreshRateBackoffFactor, long maxRefreshRateNano, java.util.function.BiFunction<HostSpec,software.amazon.awssdk.regions.Region,software.amazon.awssdk.services.rds.RdsClient> rdsClientFunc)
customEndpointHostSpec.storageService - The storage service used to store the set of allowed/blocked hosts according to the
custom endpoint info.telemetryFactory - The telemetry factory used to create telemetry data.customEndpointHostSpec - The host information for the custom endpoint to be monitored.endpointIdentifier - An endpoint identifier.region - The region of the custom endpoint to be monitored.refreshRateNano - Controls how often the custom endpoint information should be fetched and analyzed for
changes. The value specified should be in nanoseconds.maxRefreshRateNano - The maximum refresh rate allowed for the custom endpoint monitor.refreshRateBackoffFactor - The backoff factor to use when slowing down the refresh rate.rdsClientFunc - The function to call to create the RDS client that will fetch custom endpoint
information.public void monitor()
protected void speedupRefreshRate()
protected void slowdownRefreshRate()
protected void sleep(long durationNano)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected void sleepIgnoringRefreshRequests(long durationNano)
throws java.lang.InterruptedException
refreshRequired). This is used on the error/backoff paths so that the throttling backoff, and other
error delays, cannot be bypassed by incoming connections. If it could, the monitor would keep issuing RDS API
calls as fast as connections arrive, defeating the built-in rate limiting and sustaining the throttling. The
sleep still returns promptly when the monitor is stopped or the thread is interrupted.durationNano - the time to sleep, in nanoseconds.java.lang.InterruptedException - if the thread is interrupted while sleeping.public boolean hasCustomEndpointInfo()
CustomEndpointMonitorhasCustomEndpointInfo in interface CustomEndpointMonitorpublic void requestCustomEndpointInfoUpdate()
requestCustomEndpointInfoUpdate in interface CustomEndpointMonitorpublic void close()
MonitorMonitor.stop().close in interface Monitorclose in class AbstractMonitorpublic static void clearCache()
public java.util.List<Pair<java.lang.String,java.lang.Object>> getSnapshotState()
getSnapshotState in interface StateSnapshotProvider