public class FailoverConnectionProxy extends MultiHostConnectionProxy
Modifier and Type | Class and Description |
---|---|
(package private) class |
FailoverConnectionProxy.FailoverJdbcInterfaceProxy
Proxy class to intercept and deal with errors that may occur in any object bound to the current connection.
|
MultiHostConnectionProxy.JdbcInterfaceProxy
autoReconnect, closedExplicitly, closedReason, currentConnection, hostList, isClosed, lastExceptionDealtWith, localProps, proxyConnection, thisAsConnection
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
connectedToPrimaryHost()
Checks if this proxy is using the primary host in the underlying connection.
|
(package private) boolean |
connectedToSecondaryHost()
Checks if this proxy is using a secondary host in the underlying connection.
|
(package private) ConnectionImpl |
createConnectionForHostIndex(int hostIndex)
Creates a new connection instance for host pointed out by the given host index.
|
static Connection |
createProxyInstance(java.util.List<java.lang.String> hosts,
java.util.Properties props) |
(package private) void |
doAbort(java.util.concurrent.Executor executor)
Aborts current connection using the given executor.
|
(package private) void |
doAbortInternal()
Aborts current connection.
|
(package private) void |
doClose()
Closes current connection.
|
(package private) void |
fallBackToPrimaryIfAvailable()
Falls back to primary host or keep current connection if primary not available.
|
(package private) MultiHostConnectionProxy.JdbcInterfaceProxy |
getNewJdbcInterfaceProxy(java.lang.Object toProxy)
Instantiates a new JdbcInterfaceProxy for the given object.
|
(package private) void |
incrementQueriesIssuedSinceFailover()
Increments counter for query executions.
|
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.
|
(package private) boolean |
isConnected()
Checks if there is a underlying connection for this proxy.
|
(package private) boolean |
isMasterConnection()
Checks if current connection is to a master host.
|
(package private) boolean |
isPrimaryHostIndex(int hostIndex)
Checks if the given host index points to the primary host.
|
(package private) void |
pickNewConnection()
Picks the "best" connection to use from now on.
|
(package private) boolean |
readyToFallBackToPrimaryHost()
Checks if at least one of the required conditions to fall back to primary host is met, which is determined by the properties 'queriesBeforeRetryMaster'
and 'secondsBeforeRetryMaster'.
|
(package private) boolean |
shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
Checks if the given throwable should trigger a connection switch.
|
allowedOnClosedConnection, createConnectionForHost, dealWithInvocationException, getNewWrapperForThisAsConnection, getProxy, initializeHostsSpecs, invalidateConnection, invalidateCurrentConnection, invoke, propagateProxyDown, proxyIfReturnTypeIsJdbcInterface, setProxy, syncSessionState, syncSessionState
public static Connection createProxyInstance(java.util.List<java.lang.String> hosts, java.util.Properties props) throws java.sql.SQLException
java.sql.SQLException
MultiHostConnectionProxy.JdbcInterfaceProxy getNewJdbcInterfaceProxy(java.lang.Object toProxy)
MultiHostConnectionProxy
getNewJdbcInterfaceProxy
in class MultiHostConnectionProxy
toProxy
- The object instance to be proxied.boolean shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
MultiHostConnectionProxy
shouldExceptionTriggerConnectionSwitch
in class MultiHostConnectionProxy
t
- The Throwable instance to analyze.boolean isMasterConnection()
isMasterConnection
in class MultiHostConnectionProxy
void pickNewConnection() throws java.sql.SQLException
MultiHostConnectionProxy
pickNewConnection
in class MultiHostConnectionProxy
java.sql.SQLException
ConnectionImpl createConnectionForHostIndex(int hostIndex) throws java.sql.SQLException
hostIndex
- The host index in the global hosts list.java.sql.SQLException
void fallBackToPrimaryIfAvailable()
void incrementQueriesIssuedSinceFailover()
boolean readyToFallBackToPrimaryHost()
boolean isConnected()
boolean isPrimaryHostIndex(int hostIndex)
hostIndex
- The host index in the global hosts list.boolean connectedToPrimaryHost()
boolean connectedToSecondaryHost()
void doClose() throws java.sql.SQLException
doClose
in class MultiHostConnectionProxy
java.sql.SQLException
void doAbortInternal() throws java.sql.SQLException
doAbortInternal
in class MultiHostConnectionProxy
java.sql.SQLException
void doAbort(java.util.concurrent.Executor executor) throws java.sql.SQLException
doAbort
in class MultiHostConnectionProxy
java.sql.SQLException
public java.lang.Object invokeMore(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
MultiHostConnectionProxy
invokeMore
in class MultiHostConnectionProxy
java.lang.Throwable