public class SelfCorrectingDataSource
extends org.springframework.jdbc.datasource.DelegatingDataSource
implements org.springframework.context.ApplicationListener<ome.util.messages.UserSignalMessage>
DataSource delegate which wraps the| Constructor and Description |
|---|
SelfCorrectingDataSource(javax.sql.DataSource delegate,
long timeoutInMilliseconds) |
SelfCorrectingDataSource(javax.sql.DataSource delegate,
long timeoutInMilliseconds,
int maxRetries,
long maxBackOff) |
| Modifier and Type | Method and Description |
|---|---|
protected long |
calculateBackOff(int numberOfErrors) |
protected java.sql.Connection |
call(java.lang.String username,
java.lang.String password,
boolean useArgs) |
protected java.sql.Connection |
callWithRetries(java.lang.String username,
java.lang.String password,
boolean useArgs) |
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.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. |
void |
onApplicationEvent(ome.util.messages.UserSignalMessage usm)
Handles the USR1 posix signal by calling close on the underlying
data source via reflection. |
public SelfCorrectingDataSource(javax.sql.DataSource delegate,
long timeoutInMilliseconds)
public SelfCorrectingDataSource(javax.sql.DataSource delegate,
long timeoutInMilliseconds,
int maxRetries,
long maxBackOff)
public java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcegetConnection in class org.springframework.jdbc.datasource.DelegatingDataSourcejava.sql.SQLExceptionpublic java.sql.Connection getConnection(java.lang.String username,
java.lang.String password)
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcegetConnection in class org.springframework.jdbc.datasource.DelegatingDataSourcejava.sql.SQLExceptionpublic void onApplicationEvent(ome.util.messages.UserSignalMessage usm)
data source via reflection. The
assumption is that the next call to any methods will re-initialize
the data source. This is the case with
bitronix.tm.resource.jdbc.PoolingDataSourceonApplicationEvent in interface org.springframework.context.ApplicationListener<ome.util.messages.UserSignalMessage>protected java.sql.Connection callWithRetries(java.lang.String username,
java.lang.String password,
boolean useArgs)
throws java.sql.SQLException
java.sql.SQLExceptionprotected java.sql.Connection call(java.lang.String username,
java.lang.String password,
boolean useArgs)
throws java.sql.SQLException
java.sql.SQLExceptionprotected long markAndSweep()
errorTimes that are older than some
given time and then uses the remaining number of errors to determine the
backoff : (#^1/2)*1000 milliseconds.protected long calculateBackOff(int numberOfErrors)