public class ClusterAwareConnectionProxy extends MultiHostConnectionProxy implements ConnectionLifecycleInterceptorProvider
autoReconnect, closedExplicitly, closedReason, connectionUrl, currentConnection, hostsList, isClosed, lastExceptionDealtWith, thisAsConnection| Constructor and Description |
|---|
ClusterAwareConnectionProxy(ConnectionUrl connectionUrl)
Instantiates a new AuroraConnectionProxy for the given list of hosts and connection properties.
|
| Modifier and Type | Method and Description |
|---|---|
static JdbcConnection |
autodetectClusterAndCreateProxyInstance(ConnectionUrl connectionUrl)
Checks if connection is associated with Aurora cluster and instantiates a new
AuroraConnectionProxy if needed.
|
protected void |
createConnectionAndInitializeTopology(ConnectionUrl connUrl) |
protected ConnectionImpl |
createConnectionForHost(HostInfo hostInfo)
Creates a new physical connection for the given
HostInfo. |
static JdbcConnection |
createProxyInstance(ConnectionUrl connectionUrl)
Instantiates a new AuroraConnectionProxy.
|
protected void |
dealWithInvocationException(java.lang.reflect.InvocationTargetException e)
Deals with InvocationException from proxied objects.
|
protected void |
doAbort(java.util.concurrent.Executor executor)
Aborts current connection using the given executor.
|
protected void |
doAbortInternal()
Aborts current connection.
|
protected void |
doClose()
Closes current connection.
|
protected void |
failover(int failedHostIdx)
Initiates a default failover procedure starting at the given host index.
|
protected void |
failoverReader(int failedHostIdx) |
protected void |
failoverWriter() |
protected JdbcConnection |
getConnection() |
ConnectionLifecycleInterceptor |
getConnectionLifecycleInterceptor() |
protected void |
initClusterInfo(ConnectionUrl connUrl) |
protected void |
initLogger() |
protected void |
initSettings(ConnectionUrl connectionUrl) |
protected void |
invalidateCurrentConnection()
Invalidates the current connection.
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Proxies method invocation on the java.sql.Connection interface, trapping multi-host specific methods and generic methods.
|
java.lang.Object |
invokeMore(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Continuation of the method invocation process, to be implemented within each subclass.
|
boolean |
isClusterTopologyAvailable()
Checks if proxy is connected to cluster that can report its topology.
|
protected boolean |
isCurrentConnectionReadOnly() |
protected boolean |
isCurrentConnectionWriter() |
boolean |
isFailoverEnabled()
Checks if cluster-aware failover is enabled/possible.
|
protected boolean |
isMasterConnection()
Checks if current connection is to a master (writer) host.
|
boolean |
isMultiWriterCluster()
Checks if proxy is connected to multi-writer cluster.
|
boolean |
isRds()
Checks if proxy is connected to RDS-hosted cluster.
|
boolean |
isRdsProxy()
Checks if proxy is connected to cluster through RDS proxy.
|
protected void |
pickNewConnection()
Picks the "best" connection to use from now on.
|
protected void |
setConnectionProxy(JdbcConnection conn) |
protected boolean |
shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
Checks if the given throwable should trigger a connection switch.
|
protected void |
updateTopologyAndConnectIfNeeded(boolean forceUpdate) |
allowedOnClosedConnection, getNewJdbcInterfaceProxy, getParentProxy, getProxy, invalidateConnection, propagateProxyDown, proxyIfReturnTypeIsJdbcInterface, setProxy, syncSessionStateprotected static final Log NULL_LOGGER
protected transient Log log
protected static final int DEFAULT_SOCKET_TIMEOUT_MS
protected static final int DEFAULT_CONNECT_TIMEOUT_MS
protected static final int NO_CONNECTION_INDEX
protected static final int WRITER_CONNECTION_INDEX
protected int currentHostIndex
protected java.lang.Boolean explicitlyReadOnly
protected boolean inTransaction
protected boolean explicitlyAutoCommit
protected boolean isClusterTopologyAvailable
protected boolean isMultiWriterCluster
protected boolean isRdsProxy
protected boolean isRds
protected TopologyService topologyService
protected java.util.List<HostInfo> hosts
protected WriterFailoverHandler writerFailoverHandler
protected ReaderFailoverHandler readerFailoverHandler
protected ConnectionProvider connectionProvider
protected ClusterAwareMetrics metrics
protected boolean enableFailoverSetting
protected int clusterTopologyRefreshRateMsSetting
protected java.lang.String loggerClassNameSetting
protected boolean gatherPerfMetricsSetting
protected int failoverTimeoutMsSetting
protected int failoverClusterTopologyRefreshRateMsSetting
protected int failoverWriterReconnectIntervalMsSetting
protected int failoverReaderConnectTimeoutMsSetting
protected java.lang.String clusterIdSetting
protected java.lang.String clusterInstanceHostPatternSetting
protected int failoverConnectTimeoutMs
protected int failoverSocketTimeoutMs
public ClusterAwareConnectionProxy(ConnectionUrl connectionUrl) throws java.sql.SQLException
connectionUrl - ConnectionUrl instance containing the lists of hosts available to
switch on.java.sql.SQLException - if an error occurspublic static JdbcConnection autodetectClusterAndCreateProxyInstance(ConnectionUrl connectionUrl) throws java.sql.SQLException
connectionUrl - ConnectionUrl instance containing the lists of hosts available to
switch on.java.sql.SQLException - if an error occurspublic static JdbcConnection createProxyInstance(ConnectionUrl connectionUrl) throws java.sql.SQLException
connectionUrl - ConnectionUrl instance containing the lists of hosts available to
switch on.java.sql.SQLException - if an error occursprotected void initSettings(ConnectionUrl connectionUrl) throws java.sql.SQLException
java.sql.SQLExceptionprotected void initLogger()
public boolean isClusterTopologyAvailable()
public boolean isRds()
public boolean isRdsProxy()
public boolean isMultiWriterCluster()
public boolean isFailoverEnabled()
protected void initClusterInfo(ConnectionUrl connUrl) throws java.sql.SQLException
java.sql.SQLExceptionprotected void createConnectionAndInitializeTopology(ConnectionUrl connUrl) throws java.sql.SQLException
java.sql.SQLExceptionprotected void invalidateCurrentConnection()
throws java.sql.SQLException
invalidateCurrentConnection in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected void dealWithInvocationException(java.lang.reflect.InvocationTargetException e)
throws java.sql.SQLException,
java.lang.Throwable,
java.lang.reflect.InvocationTargetException
dealWithInvocationException in class MultiHostConnectionProxye - The Exception instance to check.java.sql.SQLException - if an error occursjava.lang.Throwable - if an error occursjava.lang.reflect.InvocationTargetException - if an error occursprotected boolean shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
MultiHostConnectionProxyshouldExceptionTriggerConnectionSwitch in class MultiHostConnectionProxyt - The Throwable instance to analyze.protected boolean isMasterConnection()
isMasterConnection in class MultiHostConnectionProxyprotected void pickNewConnection()
throws java.sql.SQLException
MultiHostConnectionProxypickNewConnection in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected ConnectionImpl createConnectionForHost(HostInfo hostInfo) throws java.sql.SQLException
HostInfo.createConnectionForHost in class MultiHostConnectionProxyhostInfo - The host info instance.java.sql.SQLException - if an error occursprotected void setConnectionProxy(JdbcConnection conn)
protected boolean isCurrentConnectionReadOnly()
protected boolean isCurrentConnectionWriter()
protected void failover(int failedHostIdx)
throws java.sql.SQLException
failedHostIdx - The host index where to start from. First connection attempt will be the
next one.java.sql.SQLException - if an error occursprotected void failoverWriter()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void failoverReader(int failedHostIdx)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void doClose()
throws java.sql.SQLException
doClose in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected void doAbortInternal()
throws java.sql.SQLException
doAbortInternal in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected void doAbort(java.util.concurrent.Executor executor)
throws java.sql.SQLException
doAbort in class MultiHostConnectionProxyexecutor - executorjava.sql.SQLException - if an error occursprotected void updateTopologyAndConnectIfNeeded(boolean forceUpdate)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
MultiHostConnectionProxyinvoke in interface java.lang.reflect.InvocationHandlerinvoke in class MultiHostConnectionProxyproxy - proxy objectmethod - method to invokeargs - method parametersjava.lang.Throwable - if an error occurspublic java.lang.Object invokeMore(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
MultiHostConnectionProxyinvokeMore in class MultiHostConnectionProxyproxy - proxy objectmethod - method to invokeargs - method parametersjava.lang.Throwable - if an error occurspublic ConnectionLifecycleInterceptor getConnectionLifecycleInterceptor()
getConnectionLifecycleInterceptor in interface ConnectionLifecycleInterceptorProviderprotected JdbcConnection getConnection()