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