public class ClusterTopologyMonitorImpl extends java.lang.Object implements ClusterTopologyMonitor
| Modifier and Type | Field and Description |
|---|---|
protected static int |
closeConnectionNetworkTimeoutMs |
protected java.lang.String |
clusterId |
protected HostSpec |
clusterInstanceTemplate |
protected static int |
defaultConnectionTimeoutMs |
protected static int |
defaultSocketTimeoutMs |
protected static int |
defaultTopologyQueryTimeoutMs |
protected static long |
highRefreshPeriodAfterPanicNano |
protected long |
highRefreshRateEndTimeNano |
protected long |
highRefreshRateNano |
protected HostListProviderService |
hostListProviderService |
protected java.util.concurrent.atomic.AtomicLong |
ignoreNewTopologyRequestsEndTimeNano |
protected static long |
ignoreTopologyRequestNano |
protected HostSpec |
initialHostSpec |
protected boolean |
isVerifiedWriterConnection |
protected java.util.concurrent.ExecutorService |
monitorExecutor |
protected static java.lang.String |
MONITORING_PROPERTY_PREFIX |
protected java.util.concurrent.atomic.AtomicReference<java.sql.Connection> |
monitoringConnection |
protected java.util.Properties |
monitoringProperties |
protected static java.util.concurrent.Executor |
networkTimeoutExecutor |
protected java.lang.String |
nodeIdQuery |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Thread> |
nodeThreads |
protected java.util.concurrent.atomic.AtomicReference<java.util.List<HostSpec>> |
nodeThreadsLatestTopology |
protected java.util.concurrent.atomic.AtomicReference<java.sql.Connection> |
nodeThreadsReaderConnection |
protected java.util.concurrent.atomic.AtomicBoolean |
nodeThreadsStop |
protected java.util.concurrent.atomic.AtomicReference<java.sql.Connection> |
nodeThreadsWriterConnection |
protected java.util.concurrent.atomic.AtomicReference<HostSpec> |
nodeThreadsWriterHostSpec |
protected PluginService |
pluginService |
protected java.util.Properties |
properties |
protected static RdsUtils |
rdsHelper |
protected long |
refreshRateNano |
protected java.util.concurrent.atomic.AtomicBoolean |
requestToUpdateTopology |
protected java.util.concurrent.atomic.AtomicBoolean |
stop |
protected long |
topologyCacheExpirationNano |
protected CacheMap<java.lang.String,java.util.List<HostSpec>> |
topologyMap |
protected java.lang.String |
topologyQuery |
protected java.lang.Object |
topologyUpdated |
protected java.util.concurrent.atomic.AtomicReference<HostSpec> |
writerHostSpec |
protected java.lang.String |
writerTopologyQuery |
| Constructor and Description |
|---|
ClusterTopologyMonitorImpl(java.lang.String clusterId,
CacheMap<java.lang.String,java.util.List<HostSpec>> topologyMap,
HostSpec initialHostSpec,
java.util.Properties properties,
PluginService pluginService,
HostListProviderService hostListProviderService,
HostSpec clusterInstanceTemplate,
long refreshRateNano,
long highRefreshRateNano,
long topologyCacheExpirationNano,
java.lang.String topologyQuery,
java.lang.String writerTopologyQuery,
java.lang.String nodeIdQuery) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDispose() |
void |
close() |
protected void |
closeConnection(@Nullable java.sql.Connection connection) |
protected void |
closeConnection(@Nullable java.sql.Connection connection,
boolean unstableConnection) |
protected HostSpec |
createHost(java.sql.ResultSet resultSet,
java.lang.String suggestedWriterNodeId) |
protected HostSpec |
createHost(java.lang.String nodeName,
boolean isWriter,
long weight,
java.sql.Timestamp lastUpdateTime) |
protected void |
delay(boolean useHighRefreshRate) |
protected @Nullable java.util.List<HostSpec> |
fetchTopologyAndUpdateCache(java.sql.Connection connection) |
java.util.List<HostSpec> |
forceRefresh(boolean shouldVerifyWriter,
long timeoutMs) |
java.util.List<HostSpec> |
forceRefresh(@Nullable java.sql.Connection connection,
long timeoutMs) |
protected java.lang.String |
getHostEndpoint(java.lang.String nodeName) |
protected java.lang.String |
getNodeId(java.sql.Connection connection) |
protected java.lang.Thread |
getNodeMonitoringThread(HostSpec hostSpec,
@Nullable HostSpec writerHostSpec) |
protected java.lang.String |
getSuggestedWriterNodeId(java.sql.Connection connection) |
protected java.lang.String |
getWriterNodeId(java.sql.Connection connection) |
protected boolean |
isInPanicMode() |
protected java.util.List<HostSpec> |
openAnyConnectionAndUpdateTopology() |
protected java.util.List<HostSpec> |
processQueryResults(java.sql.ResultSet resultSet,
java.lang.String suggestedWriterNodeId) |
protected java.util.List<HostSpec> |
queryForTopology(java.sql.Connection conn) |
void |
run() |
void |
setClusterId(java.lang.String clusterId) |
protected void |
updateTopologyCache(@NonNull java.util.List<HostSpec> hosts) |
protected java.util.List<HostSpec> |
waitTillTopologyGetsUpdated(long timeoutMs) |
protected static final java.lang.String MONITORING_PROPERTY_PREFIX
protected static final java.util.concurrent.Executor networkTimeoutExecutor
protected static final RdsUtils rdsHelper
protected static final int defaultTopologyQueryTimeoutMs
protected static final int closeConnectionNetworkTimeoutMs
protected static final int defaultConnectionTimeoutMs
protected static final int defaultSocketTimeoutMs
protected static final long highRefreshPeriodAfterPanicNano
protected static final long ignoreTopologyRequestNano
protected final long refreshRateNano
protected final long highRefreshRateNano
protected final long topologyCacheExpirationNano
protected final java.util.Properties properties
protected final java.util.Properties monitoringProperties
protected final PluginService pluginService
protected final HostSpec initialHostSpec
protected final java.lang.String topologyQuery
protected final java.lang.String nodeIdQuery
protected final java.lang.String writerTopologyQuery
protected final HostListProviderService hostListProviderService
protected final HostSpec clusterInstanceTemplate
protected java.lang.String clusterId
protected final java.util.concurrent.atomic.AtomicReference<HostSpec> writerHostSpec
protected final java.util.concurrent.atomic.AtomicReference<java.sql.Connection> monitoringConnection
protected boolean isVerifiedWriterConnection
protected final java.util.concurrent.atomic.AtomicBoolean stop
protected long highRefreshRateEndTimeNano
protected final java.lang.Object topologyUpdated
protected final java.util.concurrent.atomic.AtomicBoolean requestToUpdateTopology
protected final java.util.concurrent.atomic.AtomicLong ignoreNewTopologyRequestsEndTimeNano
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Thread> nodeThreads
protected final java.util.concurrent.atomic.AtomicBoolean nodeThreadsStop
protected final java.util.concurrent.atomic.AtomicReference<java.sql.Connection> nodeThreadsWriterConnection
protected final java.util.concurrent.atomic.AtomicReference<HostSpec> nodeThreadsWriterHostSpec
protected final java.util.concurrent.atomic.AtomicReference<java.sql.Connection> nodeThreadsReaderConnection
protected final java.util.concurrent.atomic.AtomicReference<java.util.List<HostSpec>> nodeThreadsLatestTopology
protected final java.util.concurrent.ExecutorService monitorExecutor
public ClusterTopologyMonitorImpl(java.lang.String clusterId,
CacheMap<java.lang.String,java.util.List<HostSpec>> topologyMap,
HostSpec initialHostSpec,
java.util.Properties properties,
PluginService pluginService,
HostListProviderService hostListProviderService,
HostSpec clusterInstanceTemplate,
long refreshRateNano,
long highRefreshRateNano,
long topologyCacheExpirationNano,
java.lang.String topologyQuery,
java.lang.String writerTopologyQuery,
java.lang.String nodeIdQuery)
public boolean canDispose()
canDispose in interface ClusterTopologyMonitorpublic void setClusterId(java.lang.String clusterId)
setClusterId in interface ClusterTopologyMonitorpublic java.util.List<HostSpec> forceRefresh(boolean shouldVerifyWriter, long timeoutMs) throws java.sql.SQLException, java.util.concurrent.TimeoutException
forceRefresh in interface ClusterTopologyMonitorjava.sql.SQLExceptionjava.util.concurrent.TimeoutExceptionpublic java.util.List<HostSpec> forceRefresh(@Nullable java.sql.Connection connection, long timeoutMs) throws java.sql.SQLException, java.util.concurrent.TimeoutException
forceRefresh in interface ClusterTopologyMonitorjava.sql.SQLExceptionjava.util.concurrent.TimeoutExceptionprotected java.util.List<HostSpec> waitTillTopologyGetsUpdated(long timeoutMs) throws java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutExceptionpublic void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exceptionpublic void run()
run in interface java.lang.Runnableprotected boolean isInPanicMode()
protected java.lang.Thread getNodeMonitoringThread(HostSpec hostSpec, @Nullable HostSpec writerHostSpec)
protected java.util.List<HostSpec> openAnyConnectionAndUpdateTopology()
protected java.lang.String getNodeId(java.sql.Connection connection)
protected void closeConnection(@Nullable java.sql.Connection connection)
protected void closeConnection(@Nullable java.sql.Connection connection,
boolean unstableConnection)
protected void delay(boolean useHighRefreshRate)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected @Nullable java.util.List<HostSpec> fetchTopologyAndUpdateCache(java.sql.Connection connection)
protected void updateTopologyCache(@NonNull java.util.List<HostSpec> hosts)
protected java.lang.String getWriterNodeId(java.sql.Connection connection)
throws java.sql.SQLException
java.sql.SQLExceptionprotected java.util.List<HostSpec> queryForTopology(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLExceptionprotected java.lang.String getSuggestedWriterNodeId(java.sql.Connection connection)
throws java.sql.SQLException
java.sql.SQLExceptionprotected java.util.List<HostSpec> processQueryResults(java.sql.ResultSet resultSet, java.lang.String suggestedWriterNodeId) throws java.sql.SQLException
java.sql.SQLExceptionprotected HostSpec createHost(java.sql.ResultSet resultSet, java.lang.String suggestedWriterNodeId) throws java.sql.SQLException
java.sql.SQLExceptionprotected HostSpec createHost(java.lang.String nodeName, boolean isWriter, long weight, java.sql.Timestamp lastUpdateTime)
protected java.lang.String getHostEndpoint(java.lang.String nodeName)