public class BlueGreenStatusMonitor
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allStartTopologyEndpointsRemoved |
protected boolean |
allStartTopologyIpChanged |
protected boolean |
allTopologyChanged |
protected static java.lang.String |
BG_CLUSTER_ID |
protected java.lang.String |
bgdId |
protected BlueGreenDialect |
blueGreenDialect |
protected java.util.concurrent.atomic.AtomicReference<java.sql.PreparedStatement> |
checkStatusStatement |
protected java.util.concurrent.atomic.AtomicBoolean |
collectIpAddresses |
protected java.util.concurrent.atomic.AtomicBoolean |
collectTopology |
protected java.util.concurrent.atomic.AtomicReference<java.lang.String> |
connectedIpAddress |
protected AtomicConnection |
connection |
protected java.util.concurrent.atomic.AtomicReference<HostSpec> |
connectionHostSpec |
protected java.util.concurrent.atomic.AtomicBoolean |
connectionHostSpecCorrect |
protected ConnectionUrlParser |
connectionUrlParser |
protected java.util.Map<java.lang.String,java.util.Optional<java.lang.String>> |
currentIpAddressesByHostMap |
protected @Nullable BlueGreenPhase |
currentPhase |
protected java.util.concurrent.atomic.AtomicReference<java.util.List<HostSpec>> |
currentTopology |
protected static long |
DEFAULT_CHECK_INTERVAL_MS |
protected java.util.concurrent.ExecutorService |
executorService |
protected @Nullable HostListProvider |
hostListProvider |
protected java.util.Set<java.lang.String> |
hostNames |
protected HostSpecBuilder |
hostSpecBuilder |
protected HostSpec |
initialHostSpec |
protected java.util.concurrent.atomic.AtomicReference<BlueGreenIntervalRate> |
intervalRate |
protected static java.util.Set<java.lang.String> |
knownVersions |
protected static java.lang.String |
latestKnownVersion |
protected @Nullable OnBlueGreenStatusChange |
onBlueGreenStatusChangeFunc |
protected java.util.concurrent.ExecutorService |
openConnectionExecutorService |
protected @Nullable java.util.concurrent.Future<java.lang.Void> |
openConnectionFuture |
protected java.util.concurrent.atomic.AtomicBoolean |
panicMode |
protected PluginService |
pluginService |
protected int |
port |
protected java.util.Properties |
props |
protected RdsUtils |
rdsUtils |
protected BlueGreenRole |
role |
protected FullServicesContainer |
servicesContainer |
protected java.lang.Object |
sleepWaitObj |
protected java.util.Map<java.lang.String,java.util.Optional<java.lang.String>> |
startIpAddressesByHostMap |
protected java.util.List<HostSpec> |
startTopology |
protected java.util.Map<BlueGreenIntervalRate,java.lang.Long> |
statusCheckIntervalMap |
protected java.util.concurrent.atomic.AtomicBoolean |
stop |
protected java.util.concurrent.atomic.AtomicBoolean |
useIpAddress |
protected java.lang.String |
version |
| Constructor and Description |
|---|
BlueGreenStatusMonitor(@NonNull BlueGreenRole role,
@NonNull java.lang.String bgdId,
@NonNull HostSpec initialHostSpec,
@NonNull FullServicesContainer servicesContainer,
@NonNull java.util.Properties props,
@NonNull java.util.Map<BlueGreenIntervalRate,java.lang.Long> statusCheckIntervalMap,
@Nullable OnBlueGreenStatusChange onBlueGreenStatusChangeFunc) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearCheckStatusStatement() |
protected void |
collectHostIpAddresses() |
protected void |
collectStatus() |
protected void |
collectTopology() |
protected void |
delay(long delayMs) |
protected java.sql.ResultSet |
executeCheckStatusStatement(java.sql.Connection conn) |
protected java.util.Optional<java.lang.String> |
getIpAddress(java.lang.String host) |
protected void |
initHostListProvider() |
protected boolean |
isConnectionClosed(@Nullable java.sql.Connection conn) |
protected void |
notifyChanges() |
protected void |
openConnection() |
void |
resetCollectedData() |
protected void |
runMonitoringLoop() |
void |
setCollectIpAddresses(boolean collectIpAddresses) |
void |
setCollectTopology(boolean collectTopology) |
void |
setIntervalRate(@NonNull BlueGreenIntervalRate blueGreenIntervalRate) |
void |
setStop(boolean stop) |
void |
setUseIpAddress(boolean useIpAddress) |
void |
start() |
protected @Nullable java.sql.Connection |
tryConnectToAllInstances(HostSpec connectionHostSpecCopy)
Attempts to connect to all known instance IPs in parallel and returns the first
successful connection.
|
protected @Nullable java.sql.Connection |
tryConnectToSingleIp(java.lang.String ip,
HostSpec connectionHostSpecCopy)
Attempts a single IP connection.
|
protected void |
updateIpAddressFlags() |
protected static final long DEFAULT_CHECK_INTERVAL_MS
protected static final java.lang.String BG_CLUSTER_ID
protected static final java.lang.String latestKnownVersion
protected static final java.util.Set<java.lang.String> knownVersions
protected final BlueGreenDialect blueGreenDialect
protected final FullServicesContainer servicesContainer
protected final PluginService pluginService
protected final java.lang.String bgdId
protected final java.util.Properties props
protected final BlueGreenRole role
protected final @Nullable OnBlueGreenStatusChange onBlueGreenStatusChangeFunc
protected final java.util.Map<BlueGreenIntervalRate,java.lang.Long> statusCheckIntervalMap
protected final HostSpec initialHostSpec
protected final java.util.concurrent.ExecutorService executorService
protected final java.util.concurrent.ExecutorService openConnectionExecutorService
protected final RdsUtils rdsUtils
protected final ConnectionUrlParser connectionUrlParser
protected final HostSpecBuilder hostSpecBuilder
protected final java.util.concurrent.atomic.AtomicBoolean collectIpAddresses
protected final java.util.concurrent.atomic.AtomicBoolean collectTopology
protected final java.util.concurrent.atomic.AtomicReference<BlueGreenIntervalRate> intervalRate
protected final java.util.concurrent.atomic.AtomicBoolean stop
protected final java.util.concurrent.atomic.AtomicBoolean useIpAddress
protected final java.lang.Object sleepWaitObj
protected @Nullable HostListProvider hostListProvider
protected java.util.List<HostSpec> startTopology
protected final java.util.concurrent.atomic.AtomicReference<java.util.List<HostSpec>> currentTopology
protected java.util.Map<java.lang.String,java.util.Optional<java.lang.String>> startIpAddressesByHostMap
protected java.util.Map<java.lang.String,java.util.Optional<java.lang.String>> currentIpAddressesByHostMap
protected boolean allStartTopologyIpChanged
protected boolean allStartTopologyEndpointsRemoved
protected boolean allTopologyChanged
protected @Nullable BlueGreenPhase currentPhase
protected java.util.Set<java.lang.String> hostNames
protected java.lang.String version
protected int port
protected AtomicConnection connection
protected final java.util.concurrent.atomic.AtomicReference<HostSpec> connectionHostSpec
protected final java.util.concurrent.atomic.AtomicReference<java.lang.String> connectedIpAddress
protected final java.util.concurrent.atomic.AtomicBoolean connectionHostSpecCorrect
protected final java.util.concurrent.atomic.AtomicBoolean panicMode
protected @Nullable java.util.concurrent.Future<java.lang.Void> openConnectionFuture
protected final java.util.concurrent.atomic.AtomicReference<java.sql.PreparedStatement> checkStatusStatement
public BlueGreenStatusMonitor(@NonNull BlueGreenRole role, @NonNull java.lang.String bgdId, @NonNull HostSpec initialHostSpec, @NonNull FullServicesContainer servicesContainer, @NonNull java.util.Properties props, @NonNull java.util.Map<BlueGreenIntervalRate,java.lang.Long> statusCheckIntervalMap, @Nullable OnBlueGreenStatusChange onBlueGreenStatusChangeFunc)
public void start()
protected void runMonitoringLoop()
protected void delay(long delayMs)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void setIntervalRate(@NonNull BlueGreenIntervalRate blueGreenIntervalRate)
public void setCollectIpAddresses(boolean collectIpAddresses)
public void setCollectTopology(boolean collectTopology)
public void setUseIpAddress(boolean useIpAddress)
public void setStop(boolean stop)
public void resetCollectedData()
protected void collectHostIpAddresses()
protected void updateIpAddressFlags()
protected java.util.Optional<java.lang.String> getIpAddress(java.lang.String host)
protected void collectTopology()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void clearCheckStatusStatement()
protected java.sql.ResultSet executeCheckStatusStatement(java.sql.Connection conn)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void collectStatus()
protected boolean isConnectionClosed(@Nullable java.sql.Connection conn)
protected void openConnection()
protected @Nullable java.sql.Connection tryConnectToAllInstances(HostSpec connectionHostSpecCopy)
AtomicConnection via
compareAndSet — the first to succeed wins, and all others close their connections
immediately. The AtomicConnection's GC-based cleanup provides a safety net for any
edge case where a connection might otherwise leak.
IP connections are prioritized over endpoint connections to avoid stale DNS data.
connectionHostSpecCopy - the host spec to use as a template (for port, etc.)protected @Nullable java.sql.Connection tryConnectToSingleIp(java.lang.String ip,
HostSpec connectionHostSpecCopy)
protected void notifyChanges()
protected void initHostListProvider()
throws java.sql.SQLException
java.sql.SQLException