| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | FailoverConnectionProxy.
Proxy class to intercept and deal with errors that may occur in any object bound to the current connection. |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private static final int | |
| private boolean | |
| private boolean | |
| private Boolean | |
| private boolean | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final int | |
| private long | |
| private int | |
| private long | |
| private long | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| private | FailoverConnectionProxy(ConnectionUrl
ConnectionUrl instance containing the lists of hosts available to switch on.Instantiates a new FailoverConnectionProxy for the given list of hosts and connection properties. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | Returns: true if soChecks if this proxy is using the primary host in the underlying connection. |
| pack-priv boolean | Returns: true if soChecks if this proxy is using a secondary host in the underlying connection. |
| private void | connectTo(int
The host index in the global hosts list. hostIndex)Connects this dynamic failover connection proxy to the host pointed out by the given host index. |
| pack-priv ConnectionImpl | Returns: The new connection instance.The host index in the global hosts list. hostIndex)Creates a new connection instance for host pointed out by the given host index. |
| public static JdbcConnection | |
| pack-priv void | doAbort(Executor
executor executor)Implements abstract com. Aborts current connection using the given executor. |
| pack-priv void | doAbortInternal()
Implements abstract com. Aborts current connection. |
| pack-priv void | doClose()
Implements abstract com. Closes current connection. |
| private void | |
| private void | failOver(int
The host index where to start from. First connection attempt will be the next one. failedHostIdx)Initiates a default failover procedure starting at the given host index. |
| pack-priv void | fallBackToPrimaryIfAvailable()
Falls back to primary host or keep current connection if primary not available. |
| pack-priv MultiHostConnectionProxy. | getNewJdbcInterfaceProxy(Object
The object instance to be proxied. toProxy)Overrides com. Gets locally bound instances of FailoverJdbcInterfaceProxy. |
| pack-priv void | |
| public Object | invokeMore(Object
proxy object proxy, Method method to invoke method, Object[] method parameters args)Implements abstract com. Continuation of the method invocation process, to be implemented within each subclass. |
| pack-priv boolean | Returns: true if there is a connectionChecks if there is a underlying connection for this proxy. |
| pack-priv boolean | Returns: true if soThe host index in the global hosts list. hostIndex)Checks if the given host index points to the primary host. |
| pack-priv boolean | isSourceConnection()
Implements abstract com. Checks if current connection is to a source host. |
| private int | Returns: next host indexCurrent host index. currHostIdx, boolean Allows to return the primary host index even if the usual required conditions aren't met. vouchForPrimaryHost)Gets the next host on the hosts list. |
| pack-priv void | pickNewConnection()
Implements abstract com. Picks the "best" connection to use from now on. |
| private boolean | Returns: valueChecks the condition set by the property 'queriesBeforeRetrySource'. |
| pack-priv boolean | Returns: true if readyChecks if at least one of the required conditions to fall back to primary host is met, which is determined by the properties 'queriesBeforeRetrySource' and 'secondsBeforeRetrySource'. |
| private void | |
| private boolean | Returns: valueChecks the condition set by the property 'secondsBeforeRetrySource'. |
| pack-priv boolean | shouldExceptionTriggerConnectionSwitch(Throwable
The Throwable instance to analyze. t)Implements abstract com. Checks if the given throwable should trigger a connection switch. |
| private void | switchCurrentConnectionTo(int
The host index in the global hosts list that matches the given connection. hostIndex, JdbcConnection The connection instance to switch to. connection)Replaces the previous underlying connection by the connection given. |
| currentHostIndex | back to summary |
|---|---|
| private int currentHostIndex | |
| DEFAULT_PRIMARY_HOST_INDEX | back to summary |
|---|---|
| private static final int DEFAULT_PRIMARY_HOST_INDEX | |
| enableFallBackToPrimaryHost | back to summary |
|---|---|
| private boolean enableFallBackToPrimaryHost | |
| explicitlyAutoCommit | back to summary |
|---|---|
| private boolean explicitlyAutoCommit | |
| explicitlyReadOnly | back to summary |
|---|---|
| private Boolean explicitlyReadOnly | |
| failoverReadOnly | back to summary |
|---|---|
| private boolean failoverReadOnly | |
| METHOD_COMMIT | back to summary |
|---|---|
| private static final String METHOD_COMMIT | |
| METHOD_ROLLBACK | back to summary |
|---|---|
| private static final String METHOD_ROLLBACK | |
| METHOD_SET_AUTO_COMMIT | back to summary |
|---|---|
| private static final String METHOD_SET_AUTO_COMMIT | |
| METHOD_SET_READ_ONLY | back to summary |
|---|---|
| private static final String METHOD_SET_READ_ONLY | |
| NO_CONNECTION_INDEX | back to summary |
|---|---|
| private static final int NO_CONNECTION_INDEX | |
| primaryHostFailTimeMillis | back to summary |
|---|---|
| private long primaryHostFailTimeMillis | |
| primaryHostIndex | back to summary |
|---|---|
| private int primaryHostIndex | |
| queriesBeforeRetryPrimaryHost | back to summary |
|---|---|
| private long queriesBeforeRetryPrimaryHost | |
| queriesIssuedSinceFailover | back to summary |
|---|---|
| private long queriesIssuedSinceFailover | |
| retriesAllDown | back to summary |
|---|---|
| private int retriesAllDown | |
| secondsBeforeRetryPrimaryHost | back to summary |
|---|---|
| private int secondsBeforeRetryPrimaryHost | |
| FailoverConnectionProxy | back to summary |
|---|---|
| private FailoverConnectionProxy(ConnectionUrl connectionUrl) throws SQLException Instantiates a new FailoverConnectionProxy for the given list of hosts and connection properties.
| |
| connectedToPrimaryHost | back to summary |
|---|---|
| pack-priv boolean connectedToPrimaryHost() Checks if this proxy is using the primary host in the underlying connection.
| |
| connectedToSecondaryHost | back to summary |
|---|---|
| pack-priv boolean connectedToSecondaryHost() Checks if this proxy is using a secondary host in the underlying connection.
| |
| connectTo | back to summary |
|---|---|
| private void connectTo(int hostIndex) throws SQLException Connects this dynamic failover connection proxy to the host pointed out by the given host index.
| |
| createConnectionForHostIndex | back to summary |
|---|---|
| pack-priv ConnectionImpl createConnectionForHostIndex(int hostIndex) throws SQLException Creates a new connection instance for host pointed out by the given host index.
| |
| createProxyInstance | back to summary |
|---|---|
| public static JdbcConnection createProxyInstance(ConnectionUrl connectionUrl) throws SQLException | |
| doAbort | back to summary |
|---|---|
| pack-priv void doAbort(Executor executor) throws SQLException Implements abstract com. Aborts current connection using the given executor.
| |
| doAbortInternal | back to summary |
|---|---|
| pack-priv void doAbortInternal() throws SQLException Implements abstract com. Aborts current connection.
| |
| doClose | back to summary |
|---|---|
| pack-priv void doClose() throws SQLException Implements abstract com. Closes current connection.
| |
| failOver | back to summary |
|---|---|
| private void failOver() throws SQLException Initiates a default failover procedure starting at the current connection host index.
| |
| failOver | back to summary |
|---|---|
| private void failOver(int failedHostIdx) throws SQLException Initiates a default failover procedure starting at the given host index. This process tries to connect, sequentially, to the next host in the list. The primary host may or may not be excluded from the connection attempts.
| |
| fallBackToPrimaryIfAvailable | back to summary |
|---|---|
| pack-priv void fallBackToPrimaryIfAvailable() Falls back to primary host or keep current connection if primary not available. | |
| getNewJdbcInterfaceProxy | back to summary |
|---|---|
| pack-priv MultiHostConnectionProxy. Overrides com. Gets locally bound instances of FailoverJdbcInterfaceProxy.
| |
| incrementQueriesIssuedSinceFailover | back to summary |
|---|---|
| pack-priv void incrementQueriesIssuedSinceFailover() Increments counter for query executions. | |
| invokeMore | back to summary |
|---|---|
| public Object invokeMore(Object proxy, Method method, Object[] args) throws Throwable Implements abstract com. Doc from com. Continuation of the method invocation process, to be implemented within each subclass. | |
| isConnected | back to summary |
|---|---|
| pack-priv boolean isConnected() Checks if there is a underlying connection for this proxy.
| |
| isPrimaryHostIndex | back to summary |
|---|---|
| pack-priv boolean isPrimaryHostIndex(int hostIndex) Checks if the given host index points to the primary host.
| |
| isSourceConnection | back to summary |
|---|---|
| pack-priv boolean isSourceConnection() Implements abstract com. Checks if current connection is to a source host.
| |
| nextHost | back to summary |
|---|---|
| private int nextHost(int currHostIdx, boolean vouchForPrimaryHost) Gets the next host on the hosts list. Uses a round-robin algorithm to find the next element, but it may skip the index for the primary host. General rules to include the primary host are: - not currently connected to any host. - primary host is vouched (usually because connection to all secondary hosts has failed). - conditions to fall back to primary host are met (or they are disabled).
| |
| pickNewConnection | back to summary |
|---|---|
| pack-priv void pickNewConnection() throws SQLException Implements abstract com. Doc from com. Picks the "best" connection to use from now on. Each subclass needs to implement its connection switch strategy on it.
| |
| queriesBeforeRetryPrimaryHostIsMet | back to summary |
|---|---|
| private boolean queriesBeforeRetryPrimaryHostIsMet() Checks the condition set by the property 'queriesBeforeRetrySource'.
| |
| readyToFallBackToPrimaryHost | back to summary |
|---|---|
| pack-priv 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 'queriesBeforeRetrySource' and 'secondsBeforeRetrySource'.
| |
| resetAutoFallBackCounters | back to summary |
|---|---|
| private void resetAutoFallBackCounters() Resets auto-fall back counters. | |
| secondsBeforeRetryPrimaryHostIsMet | back to summary |
|---|---|
| private boolean secondsBeforeRetryPrimaryHostIsMet() Checks the condition set by the property 'secondsBeforeRetrySource'.
| |
| shouldExceptionTriggerConnectionSwitch | back to summary |
|---|---|
| pack-priv boolean shouldExceptionTriggerConnectionSwitch(Throwable t) Implements abstract com. Doc from com. Checks if the given throwable should trigger a connection switch. | |
| switchCurrentConnectionTo | back to summary |
|---|---|
| private void switchCurrentConnectionTo(int hostIndex, JdbcConnection connection) throws SQLException Replaces the previous underlying connection by the connection given. State from previous connection, if any, is synchronized with the new one.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Object | invoke(Object
the proxy instance that the method was invoked on proxy, Method the method, Object[] Method instance corresponding to
the interface method invoked on the proxy instance. The declaring
class of the Method object will be the interface that
the method was declared in, which may be a superinterface of the
proxy interface that the proxy class inherits the method through.an array of objects containing the values of the
arguments passed in the method invocation on the proxy instance,
or args)null if interface method takes no arguments.
Arguments of primitive types are wrapped in instances of the
appropriate primitive wrapper class, such as
java.lang.Integer or java.lang.Boolean.Overrides com. Implements java. Processes a method invocation on a proxy instance and returns the result. |
| FailoverJdbcInterfaceProxy | back to summary |
|---|---|
| pack-priv FailoverJdbcInterfaceProxy(Object toInvokeOn) | |
| invoke | back to summary |
|---|---|
| public Object invoke(Object proxy, Method method, Object[] args) throws Throwable Overrides com. Implements java. Doc from java. Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.
| |