public class ClusterTopologyMonitorImpl extends AbstractMonitor implements ClusterTopologyMonitor, StateSnapshotProvider
| Modifier and Type | Field and Description |
|---|---|
protected static int |
closeConnectionNetworkTimeoutMs |
protected java.lang.String |
clusterId |
protected java.util.Map<java.lang.String,java.lang.Boolean> |
completedOneCycle |
protected static int |
defaultConnectionTimeoutMs |
protected static int |
defaultSocketTimeoutMs |
protected static long |
highRefreshPeriodAfterPanicNano |
protected long |
highRefreshRateEndTimeNano |
protected long |
highRefreshRateNano |
protected java.util.function.Function<HostSpec,java.util.List<java.lang.Object>> |
hostSpecExtractor |
protected HostSpec |
initialHostSpec |
protected HostSpec |
instanceTemplate |
protected boolean |
isVerifiedWriterConnection |
protected boolean |
logUnclosedConnections |
protected static java.lang.String |
MONITORING_PROPERTY_PREFIX |
protected AtomicConnection |
monitoringConnection |
protected java.util.Properties |
monitoringProperties |
protected static long |
monitorTerminationTimeoutSec |
protected static java.util.concurrent.Executor |
networkTimeoutExecutor |
protected ResourceLock |
nodeExecutorLock |
protected java.util.concurrent.ExecutorService |
nodeExecutorService |
protected java.util.concurrent.atomic.AtomicReference<java.util.List<HostSpec>> |
nodeThreadsLatestTopology |
protected AtomicConnection |
nodeThreadsReaderConnection |
protected java.util.concurrent.atomic.AtomicBoolean |
nodeThreadsStop |
protected AtomicConnection |
nodeThreadsWriterConnection |
protected java.util.concurrent.atomic.AtomicReference<HostSpec> |
nodeThreadsWriterHostSpec |
protected java.util.Properties |
properties |
protected static RdsUtils |
rdsHelper |
protected java.util.Map<java.lang.String,java.util.List<HostSpec>> |
readerTopologiesById |
protected long |
refreshRateNano |
protected java.util.concurrent.atomic.AtomicBoolean |
requestToUpdateTopology |
protected FullServicesContainer |
servicesContainer |
protected long |
stableTopologiesDurationNano |
protected long |
stableTopologiesStartNano |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Boolean> |
submittedNodes |
protected java.lang.Object |
topologyUpdated |
protected TopologyUtils |
topologyUtils |
protected java.util.concurrent.atomic.AtomicReference<HostSpec> |
writerHostSpec |
lastActivityTimestampNanos, monitorExecutor, state, stop, terminationTimeoutSec| Constructor and Description |
|---|
ClusterTopologyMonitorImpl(FullServicesContainer servicesContainer,
TopologyUtils topologyUtils,
java.lang.String clusterId,
HostSpec initialHostSpec,
java.util.Properties properties,
HostSpec instanceTemplate,
long refreshRateNano,
long highRefreshRateNano) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDispose()
Defines whether this monitor can be disposed.
|
protected void |
checkForStableReaderTopologies() |
protected void |
clearTopologyCache() |
void |
close()
Closes all resources used by this monitor.
|
protected void |
closeConnection(@Nullable java.sql.Connection connection) |
protected void |
closeNodeMonitors() |
protected void |
createNodeExecutorService() |
protected void |
delay(boolean useHighRefreshRate) |
protected @Nullable java.util.List<HostSpec> |
fetchTopologyAndUpdateCache(java.sql.Connection connection) |
java.util.List<HostSpec> |
forceRefresh(boolean verifyTopology,
long timeoutMs) |
protected HostSpec |
getInstanceTemplate(java.lang.String nodeId,
java.sql.Connection connection) |
protected java.lang.Runnable |
getNodeMonitoringWorker(HostSpec hostSpec,
@Nullable HostSpec writerHostSpec) |
java.util.List<Pair<java.lang.String,java.lang.Object>> |
getSnapshotState() |
protected boolean |
isInPanicMode() |
void |
monitor()
Executes the monitoring loop for this monitor.
|
protected void |
nodeThreadConnectionCleanUp() |
protected java.util.List<HostSpec> |
openAnyConnectionAndUpdateTopology() |
void |
processEvent(Event event)
Processes an event.
|
protected java.util.List<HostSpec> |
queryForTopology(java.sql.Connection connection) |
protected void |
reset() |
void |
stop()
Stops the monitoring tasks for this monitor and closes all resources.
|
protected void |
updateHostsAvailability(@NonNull java.util.List<HostSpec> hosts) |
protected void |
updateTopologyCache(@NonNull java.util.List<HostSpec> hosts) |
protected java.util.List<HostSpec> |
waitForTopologyUpdate(long timeoutMs) |
getLastActivityTimestampNanos, getState, run, startclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLastActivityTimestampNanos, getState, startprotected static final java.lang.String MONITORING_PROPERTY_PREFIX
protected static final java.util.concurrent.Executor networkTimeoutExecutor
protected static final RdsUtils rdsHelper
protected static final long monitorTerminationTimeoutSec
protected static final int closeConnectionNetworkTimeoutMs
protected static final int defaultConnectionTimeoutMs
protected static final int defaultSocketTimeoutMs
protected static final long highRefreshPeriodAfterPanicNano
protected final java.util.concurrent.atomic.AtomicReference<HostSpec> writerHostSpec
protected AtomicConnection monitoringConnection
protected final java.lang.Object topologyUpdated
protected final java.util.concurrent.atomic.AtomicBoolean requestToUpdateTopology
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Boolean> submittedNodes
protected final ResourceLock nodeExecutorLock
protected final java.util.concurrent.atomic.AtomicBoolean nodeThreadsStop
protected AtomicConnection nodeThreadsWriterConnection
protected final java.util.concurrent.atomic.AtomicReference<HostSpec> nodeThreadsWriterHostSpec
protected final AtomicConnection nodeThreadsReaderConnection
protected final java.util.concurrent.atomic.AtomicReference<java.util.List<HostSpec>> nodeThreadsLatestTopology
protected final java.util.Map<java.lang.String,java.util.List<HostSpec>> readerTopologiesById
protected final java.util.Map<java.lang.String,java.lang.Boolean> completedOneCycle
protected final long stableTopologiesDurationNano
protected long stableTopologiesStartNano
protected java.util.function.Function<HostSpec,java.util.List<java.lang.Object>> hostSpecExtractor
protected final long refreshRateNano
protected final long highRefreshRateNano
protected final TopologyUtils topologyUtils
protected final FullServicesContainer servicesContainer
protected final java.util.Properties properties
protected final java.util.Properties monitoringProperties
protected final HostSpec initialHostSpec
protected final HostSpec instanceTemplate
protected java.util.concurrent.ExecutorService nodeExecutorService
protected boolean isVerifiedWriterConnection
protected long highRefreshRateEndTimeNano
protected java.lang.String clusterId
protected boolean logUnclosedConnections
public ClusterTopologyMonitorImpl(FullServicesContainer servicesContainer, TopologyUtils topologyUtils, java.lang.String clusterId, HostSpec initialHostSpec, java.util.Properties properties, HostSpec instanceTemplate, long refreshRateNano, long highRefreshRateNano)
public boolean canDispose()
MonitorcanDispose in interface ClusterTopologyMonitorcanDispose in interface MonitorcanDispose in class AbstractMonitorpublic java.util.List<HostSpec> forceRefresh(boolean verifyTopology, long timeoutMs) throws java.sql.SQLException, java.util.concurrent.TimeoutException
forceRefresh in interface ClusterTopologyMonitorjava.sql.SQLExceptionjava.util.concurrent.TimeoutExceptionprotected java.util.List<HostSpec> waitForTopologyUpdate(long timeoutMs) throws java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutExceptionpublic void stop()
Monitorstop in interface Monitorstop in class AbstractMonitorpublic void close()
MonitorMonitor.stop().close in interface Monitorclose in class AbstractMonitorpublic 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.protected void checkForStableReaderTopologies()
protected void reset()
public void processEvent(Event event)
EventSubscriberEventPublisher.subscribe(software.amazon.jdbc.util.events.EventSubscriber, java.util.Set<java.lang.Class<? extends software.amazon.jdbc.util.events.Event>>).processEvent in interface EventSubscriberevent - the event to process.protected void nodeThreadConnectionCleanUp()
protected void closeNodeMonitors()
protected void createNodeExecutorService()
protected boolean isInPanicMode()
protected java.lang.Runnable getNodeMonitoringWorker(HostSpec hostSpec, @Nullable HostSpec writerHostSpec) throws java.sql.SQLException
java.sql.SQLExceptionprotected java.util.List<HostSpec> openAnyConnectionAndUpdateTopology()
protected HostSpec getInstanceTemplate(java.lang.String nodeId, java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLExceptionprotected void closeConnection(@Nullable java.sql.Connection connection)
protected void delay(boolean useHighRefreshRate)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected @Nullable java.util.List<HostSpec> fetchTopologyAndUpdateCache(java.sql.Connection connection)
protected java.util.List<HostSpec> queryForTopology(java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLExceptionprotected void updateHostsAvailability(@NonNull java.util.List<HostSpec> hosts)
protected void updateTopologyCache(@NonNull java.util.List<HostSpec> hosts)
protected void clearTopologyCache()
public java.util.List<Pair<java.lang.String,java.lang.Object>> getSnapshotState()
getSnapshotState in interface StateSnapshotProvider