提交 8f21cb1a 编写于 作者: J Johnny Lim 提交者: Juergen Hoeller

Polish DatabaseStartupValidator

上级 bfb2effd
......@@ -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");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册