Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mysql.jdbc
Class BestResponseTimeBalanceStrategy

    java.lang.Object
      com.mysql.jdbc.BestResponseTimeBalanceStrategy

All Implemented Interfaces:
  BalanceStrategy, Extension

    public class BestResponseTimeBalanceStrategy

extends java.lang.Object
implements BalanceStrategy

Constructor Summary
`BestResponseTimeBalanceStrategy()`

Method Summary
`void` | `destroy()` Called by the driver when this extension should release any resources it is holding and cleanup internally before the connection is closed.
`void` | `init(Connection conn, java.util.Properties props)` Called once per connection that wants to use the extension The properties are the same ones passed in in the URL or arguments to Driver.connect() or DriverManager.getConnection().
`ConnectionImpl` | `pickConnection(LoadBalancingConnectionProxy proxy, java.util.List<java.lang.String> configuredHosts, java.util.Map<java.lang.String,ConnectionImpl> liveConnections, long[] responseTimes, int numRetries)` Called by the driver to pick a new connection to route requests over.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BestResponseTimeBalanceStrategy

    public BestResponseTimeBalanceStrategy()

Parameters:
  `loadBalancingConnectionProxy` -

Method Detail

### destroy

    public void destroy()

  Description copied from interface: `Extension`
  Called by the driver when this extension should release any resources it is holding and cleanup internally before the connection is closed.

  Specified by:
    `destroy` in interface `Extension`

### init

    public void init(Connection conn,
                     java.util.Properties props)
              throws java.sql.SQLException

  Description copied from interface: `Extension`
  Called once per connection that wants to use the extension The properties are the same ones passed in in the URL or arguments to Driver.connect() or DriverManager.getConnection().

  Specified by:
    `init` in interface `Extension`
  Parameters:
    `conn` - the connection for which this extension is being created
    `props` - configuration values as passed to the connection. Note that in order to support javax.sql.DataSources, configuration properties specific to an interceptor must be passed via setURL() on the DataSource. Extension properties are not exposed via accessor/mutator methods on DataSources.
  Throws:
    `java.sql.SQLException` - should be thrown if the the Extension can not initialize itself.

### pickConnection

    public ConnectionImpl pickConnection(LoadBalancingConnectionProxy proxy,
                                         java.util.List<java.lang.String> configuredHosts,
                                         java.util.Map<java.lang.String,ConnectionImpl> liveConnections,
                                         long[] responseTimes,
                                         int numRetries)
                                  throws java.sql.SQLException

  Description copied from interface: `BalanceStrategy`
  Called by the driver to pick a new connection to route requests over.

  Specified by:
    `pickConnection` in interface `BalanceStrategy`
  Parameters:
    `proxy` - the InvocationHandler that deals with actual method calls to the JDBC connection, and serves as a factory for new connections for this strategy via the createConnectionForHost() method. This proxy takes care of maintaining the response time list, map of host/ports to live connections, and taking connections out of the live connections map if they receive a network-related error while they are in use by the application.
    `configuredHosts` - the list of hosts/ports (in "host:port" form) as passed in by the user.
    `liveConnections` - a map of host/ports to "live" connections to them.
    `responseTimes` - the list of response times for a transaction for each host in the configured hosts list.
    `numRetries` - the number of times the driver expects this strategy to re-try connection attempts if creating a new connection fails.
  Returns:
    the physical JDBC connection for the application to use, based upon the strategy employed.
  Throws:
    `java.sql.SQLException` - if a new connection can not be found or created by this strategy.
  See Also:
    `LoadBalancingConnectionProxy.createConnectionForHost(String)`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD