Polish DatabaseStartupValidator
This commit is contained in:
committed by
Juergen Hoeller
parent
bfb2effddb
commit
8f21cb1a7c
@@ -76,7 +76,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
|
||||
/**
|
||||
* Set the interval between validation runs (in seconds).
|
||||
* Default is 1.
|
||||
* Default is {@value #DEFAULT_INTERVAL}.
|
||||
*/
|
||||
public void setInterval(int interval) {
|
||||
this.interval = interval;
|
||||
@@ -84,7 +84,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
|
||||
/**
|
||||
* Set the timeout (in seconds) after which a fatal exception
|
||||
* will be thrown. Default is 60.
|
||||
* will be thrown. Default is {@value #DEFAULT_TIMEOUT}.
|
||||
*/
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -127,11 +127,15 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
latestEx = ex;
|
||||
logger.debug("Validation query [" + this.validationQuery + "] threw exception", ex);
|
||||
float rest = ((float) (deadLine - System.currentTimeMillis())) / 1000;
|
||||
if (rest > this.interval) {
|
||||
logger.warn("Database has not started up yet - retrying in " + this.interval +
|
||||
" seconds (timeout in " + rest + " seconds)");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Validation query [" + this.validationQuery + "] threw exception", ex);
|
||||
}
|
||||
if (logger.isWarnEnabled()) {
|
||||
float rest = ((float) (deadLine - System.currentTimeMillis())) / 1000;
|
||||
if (rest > this.interval) {
|
||||
logger.warn("Database has not started up yet - retrying in " + this.interval +
|
||||
" seconds (timeout in " + rest + " seconds)");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -149,8 +153,8 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
"Database has not started up within " + this.timeout + " seconds", latestEx);
|
||||
}
|
||||
|
||||
float duration = (System.currentTimeMillis() - beginTime)*1f / 1000;
|
||||
if (logger.isInfoEnabled()) {
|
||||
float duration = ((float) (System.currentTimeMillis() - beginTime)) / 1000;
|
||||
logger.info("Database startup detected after " + duration + " seconds");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user