|
|
@ -52,9 +52,10 @@ public class JobScheduleHelper {
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
while (!scheduleThreadToStop) {
|
|
|
|
while (!scheduleThreadToStop) {
|
|
|
|
|
|
|
|
|
|
|
|
// 扫描任务
|
|
|
|
// Scan Job
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
PreparedStatement preparedStatement = null;
|
|
|
|
|
|
|
|
boolean preReadSuc = true;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (conn==null || conn.isClosed()) {
|
|
|
|
if (conn==null || conn.isClosed()) {
|
|
|
|
conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection();
|
|
|
|
conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection();
|
|
|
@ -154,6 +155,8 @@ public class JobScheduleHelper {
|
|
|
|
XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);
|
|
|
|
XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
preReadSuc = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// tx stop
|
|
|
|
// tx stop
|
|
|
@ -187,16 +190,19 @@ public class JobScheduleHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
long cost = System.currentTimeMillis()-start;
|
|
|
|
long cost = System.currentTimeMillis()-start;
|
|
|
|
|
|
|
|
|
|
|
|
// next second, align second
|
|
|
|
|
|
|
|
|
|
|
|
// Wait seconds, align second
|
|
|
|
|
|
|
|
if (cost < 1000) { // scan-overtime, not wait
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (cost < 1000) {
|
|
|
|
// pre-read success, exist job in 5s, wait 1s;
|
|
|
|
TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis()%1000);
|
|
|
|
// pre-read fail, no exist job in 5s, wait 1s
|
|
|
|
}
|
|
|
|
TimeUnit.MILLISECONDS.sleep((preReadSuc?1000:4000) - System.currentTimeMillis()%1000);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
if (!scheduleThreadToStop) {
|
|
|
|
if (!scheduleThreadToStop) {
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (conn != null) {
|
|
|
|
if (conn != null) {
|
|
|
|