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 baseHostInfo)
Creates a new physical connection for the given
HostInfo. |
static JdbcConnection |
createProxyInstance(ConnectionUrl connectionUrl)
Instantiates a new AuroraConnectionProxy.
|
protected void |
dealWithIllegalStateException(java.lang.IllegalStateException e) |
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 the failover procedure.
|
protected void |
failoverReader(int failedHostIdx) |
protected void |
failoverWriter() |
protected JdbcConnection |
getConnection() |
ConnectionLifecycleInterceptor |
getConnectionLifecycleInterceptor() |
protected java.lang.reflect.InvocationHandler |
getNewJdbcInterfaceProxy(java.lang.Object toProxy)
Instantiates a new JdbcInterfaceProxy for the given object.
|
protected void |
initLogger(ConnectionUrl connUrl) |
protected void |
initProxy(ConnectionUrl connUrl) |
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)
Local method invocation handling for this proxy.
|
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.
|
boolean |
isMultiWriterCluster()
Checks if proxy is connected to multi-writer cluster.
|
boolean |
isRds()
Checks if the proxy is connected to an RDS-hosted cluster.
|
boolean |
isRdsProxy()
Checks if the proxy is connected to a cluster using RDS proxy.
|
protected boolean |
isSourceConnection()
Checks if current connection is to a master (writer) host.
|
protected void |
pickNewConnection()
Local implementation for the new connection picker.
|
protected void |
setConnectionProxy(JdbcConnection conn) |
protected boolean |
shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
Local implementation for the connection switch exception checker.
|
protected void |
updateTopologyAndConnectIfNeeded(boolean forceUpdate) |
allowedOnClosedConnection, 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.util.Map<java.lang.String,java.lang.String> initialConnectionProps
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 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 boolean isFailoverEnabled()
public 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(ConnectionUrl connUrl)
protected void initProxy(ConnectionUrl connUrl) throws java.sql.SQLException
java.sql.SQLExceptionprotected void createConnectionAndInitializeTopology(ConnectionUrl connUrl) throws java.sql.SQLException
java.sql.SQLExceptionprotected void setConnectionProxy(JdbcConnection conn)
protected void pickNewConnection()
throws java.sql.SQLException
pickNewConnection in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected ConnectionImpl createConnectionForHost(HostInfo baseHostInfo) throws java.sql.SQLException
HostInfo.createConnectionForHost in class MultiHostConnectionProxybaseHostInfo - The host info instance to base the connection off of.java.sql.SQLException - if an error occursprotected void failover(int failedHostIdx)
throws java.sql.SQLException
failedHostIdx - The index of the host that failedjava.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 updateTopologyAndConnectIfNeeded(boolean forceUpdate)
throws java.sql.SQLException
java.sql.SQLExceptionpublic boolean isRds()
public boolean isRdsProxy()
public 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
invokeMore in class MultiHostConnectionProxyproxy - proxy objectmethod - method to invokeargs - method parametersjava.lang.Throwable - 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 void dealWithIllegalStateException(java.lang.IllegalStateException e)
throws java.lang.Throwable
java.lang.Throwableprotected boolean shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
shouldExceptionTriggerConnectionSwitch in class MultiHostConnectionProxyt - The Throwable instance to analyze.protected void invalidateCurrentConnection()
throws java.sql.SQLException
invalidateCurrentConnection in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected void doClose()
throws java.sql.SQLException
doClose 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 doAbortInternal()
throws java.sql.SQLException
doAbortInternal in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected java.lang.reflect.InvocationHandler getNewJdbcInterfaceProxy(java.lang.Object toProxy)
MultiHostConnectionProxygetNewJdbcInterfaceProxy in class MultiHostConnectionProxytoProxy - The object instance to be proxied.protected boolean isSourceConnection()
isSourceConnection in class MultiHostConnectionProxypublic ConnectionLifecycleInterceptor getConnectionLifecycleInterceptor()
getConnectionLifecycleInterceptor in interface ConnectionLifecycleInterceptorProviderprotected boolean isCurrentConnectionReadOnly()
protected boolean isCurrentConnectionWriter()
protected JdbcConnection getConnection()
public boolean isClusterTopologyAvailable()
public boolean isMultiWriterCluster()