ome.services.db
Class SelfCorrectingDataSource

java.lang.Object
  extended by org.springframework.jdbc.datasource.DelegatingDataSource
      extended by ome.services.db.SelfCorrectingDataSource
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, org.springframework.beans.factory.InitializingBean

public class SelfCorrectingDataSource
extends org.springframework.jdbc.datasource.DelegatingDataSource

DataSource delegate which wraps the


Constructor Summary
SelfCorrectingDataSource(DataSource delegate, long timeoutInMilliseconds)
           
SelfCorrectingDataSource(DataSource delegate, long timeoutInMilliseconds, int maxRetries, long maxBackOff)
           
 
Method Summary
protected  long calculateBackOff(int numberOfErrors)
           
protected  Connection call(String username, String password, boolean useArgs)
           
protected  Connection callWithRetries(String username, String password, boolean useArgs)
           
 Connection getConnection()
           
 Connection getConnection(String username, String password)
           
protected  long markAndSweep()
          First removes all entries in errorTimes that are older than some given time and then uses the remaining number of errors to determine the backoff : (#^1/2)*1000 milliseconds.
 
Methods inherited from class org.springframework.jdbc.datasource.DelegatingDataSource
afterPropertiesSet, getLoginTimeout, getLogWriter, getTargetDataSource, isWrapperFor, setLoginTimeout, setLogWriter, setTargetDataSource, unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelfCorrectingDataSource

public SelfCorrectingDataSource(DataSource delegate,
                                long timeoutInMilliseconds)

SelfCorrectingDataSource

public SelfCorrectingDataSource(DataSource delegate,
                                long timeoutInMilliseconds,
                                int maxRetries,
                                long maxBackOff)
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface DataSource
Overrides:
getConnection in class org.springframework.jdbc.datasource.DelegatingDataSource
Throws:
SQLException

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException
Specified by:
getConnection in interface DataSource
Overrides:
getConnection in class org.springframework.jdbc.datasource.DelegatingDataSource
Throws:
SQLException

callWithRetries

protected Connection callWithRetries(String username,
                                     String password,
                                     boolean useArgs)
                              throws SQLException
Throws:
SQLException

call

protected Connection call(String username,
                          String password,
                          boolean useArgs)
                   throws SQLException
Throws:
SQLException

markAndSweep

protected long markAndSweep()
First removes all entries in errorTimes that are older than some given time and then uses the remaining number of errors to determine the backoff : (#^1/2)*1000 milliseconds.


calculateBackOff

protected long calculateBackOff(int numberOfErrors)


OmeroJava Api

Version: 4.3.3-00d1137e-b2894

Copyright © 2009 The University of Dundee. All Rights Reserved.