| java.lang.Object com.mysql.jdbc.LoadBalancingConnectionProxy
LoadBalancingConnectionProxy | public class LoadBalancingConnectionProxy implements InvocationHandler,PingTarget(Code) | | An implementation of java.sql.Connection that load balances requests across a
series of MySQL JDBC connections, where the balancing takes place at
transaction commit.
Therefore, for this to work (at all), you must use transactions, even if only
reading data.
This implementation will invalidate connections that it detects have had
communication errors when processing a request. A new connection to the
problematic host will be attempted the next time it is selected by the load
balancing algorithm.
This implementation is thread-safe, but it's questionable whether sharing a
connection instance amongst threads is a good idea, given that transactions
are scoped to connections in JDBC.
version: $Id: $ |
Inner Class :interface BalanceStrategy | |
Inner Class :class BestResponseTimeBalanceStrategy implements BalanceStrategy | |
Inner Class :protected class ConnectionErrorFiringInvocationHandler implements InvocationHandler | |
Inner Class :class RandomBalanceStrategy implements BalanceStrategy | |
Constructor Summary | |
| LoadBalancingConnectionProxy(List hosts, Properties props) Creates a proxy for java.sql.Connection that routes requests between the
given list of host:port and uses the given properties when creating
connections. |
balancer | BalanceStrategy balancer(Code) | | |
inTransaction | boolean inTransaction(Code) | | |
isClosed | boolean isClosed(Code) | | |
transactionStartTime | long transactionStartTime(Code) | | |
LoadBalancingConnectionProxy | LoadBalancingConnectionProxy(List hosts, Properties props) throws SQLException(Code) | | Creates a proxy for java.sql.Connection that routes requests between the
given list of host:port and uses the given properties when creating
connections.
Parameters: hosts - Parameters: props - throws: SQLException - |
invalidateCurrentConnection | synchronized void invalidateCurrentConnection() throws SQLException(Code) | | Closes current connection and removes it from required mappings.
throws: SQLException - |
invoke | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable(Code) | | Proxies method invocation on the java.sql.Connection interface, trapping
"close", "isClosed" and "commit/rollback" (to switch connections for load
balancing).
|
proxyIfInterfaceIsJdbc | Object proxyIfInterfaceIsJdbc(Object toProxy, Class clazz)(Code) | | Recursively checks for interfaces on the given object to determine if it
implements a java.sql interface, and if so, proxies the instance so that
we can catch and fire SQL errors.
Parameters: toProxy - Parameters: clazz - |
|
|