Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
7ab75aa8
提交
7ab75aa8
authored
11月 22, 2019
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调度报表优化:新增日志报表的存储表,三天内的任务日志会以每分钟一次的频率异步同步至报表中;任务报表仅读取报表数据,极大提升加载速度;
上级
24cc161b
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
336 行增加
和
58 行删除
+336
-58
XXL-JOB官方文档.md
doc/XXL-JOB官方文档.md
+2
-1
tables_xxl_job.sql
doc/db/tables_xxl_job.sql
+10
-0
XxlJobAdminConfig.java
...n/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java
+7
-4
XxlJobLogReport.java
...in/java/com/xxl/job/admin/core/model/XxlJobLogReport.java
+54
-0
XxlJobScheduler.java
...ava/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java
+7
-4
JobFailMonitorHelper.java
...a/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java
+9
-1
JobLogReportHelper.java
...ava/com/xxl/job/admin/core/thread/JobLogReportHelper.java
+121
-0
JobScheduleHelper.java
...java/com/xxl/job/admin/core/thread/JobScheduleHelper.java
+1
-0
XxlJobLogDao.java
...min/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java
+1
-3
XxlJobLogReportDao.java
...c/main/java/com/xxl/job/admin/dao/XxlJobLogReportDao.java
+26
-0
XxlJobServiceImpl.java
...ava/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
+21
-26
XxlJobLogMapper.xml
...min/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml
+10
-11
XxlJobLogReportMapper.xml
...c/main/resources/mybatis-mapper/XxlJobLogReportMapper.xml
+63
-0
XxlJobLogDaoTest.java
...src/test/java/com/xxl/job/admin/dao/XxlJobLogDaoTest.java
+0
-4
DateUtil.java
...ob-core/src/main/java/com/xxl/job/core/util/DateUtil.java
+4
-4
没有找到文件。
doc/XXL-JOB官方文档.md
浏览文件 @
7ab75aa8
...
@@ -1598,7 +1598,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -1598,7 +1598,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
20、xxl-rpc服务端线程优化,降低线程内存开销;
-
20、xxl-rpc服务端线程优化,降低线程内存开销;
-
21、调度中心回调API服务改为restful方式;
-
21、调度中心回调API服务改为restful方式;
-
22、调度中心日志删除优化,改为分页获取ID并根据ID删除的方式,避免批量删除海量日志导致死锁问题;
-
22、调度中心日志删除优化,改为分页获取ID并根据ID删除的方式,避免批量删除海量日志导致死锁问题;
-
23、
[
ING
]
调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表;
-
23、调度报表优化:新增日志报表的存储表,三天内的任务日志会以每分钟一次的频率异步同步至报表中;任务报表仅读取报表数据,极大提升加载速度;
-
24、
[
ing
]
调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表;
...
...
doc/db/tables_xxl_job.sql
浏览文件 @
7ab75aa8
...
@@ -53,6 +53,16 @@ CREATE TABLE `xxl_job_log` (
...
@@ -53,6 +53,16 @@ CREATE TABLE `xxl_job_log` (
KEY
`I_handle_code`
(
`handle_code`
)
KEY
`I_handle_code`
(
`handle_code`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`xxl_job_log_report`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`trigger_day`
datetime
DEFAULT
NULL
COMMENT
'调度-时间'
,
`running_count`
int
(
11
)
NOT
NULL
DEFAULT
'0'
COMMENT
'运行中-日志数量'
,
`suc_count`
int
(
11
)
NOT
NULL
DEFAULT
'0'
COMMENT
'执行成功-日志数量'
,
`fail_count`
int
(
11
)
NOT
NULL
DEFAULT
'0'
COMMENT
'执行失败-日志数量'
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`i_trigger_day`
(
`trigger_day`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`xxl_job_logglue`
(
CREATE
TABLE
`xxl_job_logglue`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`job_id`
int
(
11
)
NOT
NULL
COMMENT
'任务,主键ID'
,
`job_id`
int
(
11
)
NOT
NULL
COMMENT
'任务,主键ID'
,
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java
浏览文件 @
7ab75aa8
package
com
.
xxl
.
job
.
admin
.
core
.
conf
;
package
com
.
xxl
.
job
.
admin
.
core
.
conf
;
import
com.xxl.job.admin.core.scheduler.XxlJobScheduler
;
import
com.xxl.job.admin.core.scheduler.XxlJobScheduler
;
import
com.xxl.job.admin.dao.XxlJobGroupDao
;
import
com.xxl.job.admin.dao.*
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -76,6 +73,8 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
...
@@ -76,6 +73,8 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
@Resource
@Resource
private
XxlJobGroupDao
xxlJobGroupDao
;
private
XxlJobGroupDao
xxlJobGroupDao
;
@Resource
@Resource
private
XxlJobLogReportDao
xxlJobLogReportDao
;
@Resource
private
JavaMailSender
mailSender
;
private
JavaMailSender
mailSender
;
@Resource
@Resource
private
DataSource
dataSource
;
private
DataSource
dataSource
;
...
@@ -123,6 +122,10 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
...
@@ -123,6 +122,10 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
return
xxlJobGroupDao
;
return
xxlJobGroupDao
;
}
}
public
XxlJobLogReportDao
getXxlJobLogReportDao
()
{
return
xxlJobLogReportDao
;
}
public
JavaMailSender
getMailSender
()
{
public
JavaMailSender
getMailSender
()
{
return
mailSender
;
return
mailSender
;
}
}
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLogReport.java
0 → 100644
浏览文件 @
7ab75aa8
package
com
.
xxl
.
job
.
admin
.
core
.
model
;
import
java.util.Date
;
public
class
XxlJobLogReport
{
private
int
id
;
private
Date
triggerDay
;
private
int
runningCount
;
private
int
sucCount
;
private
int
failCount
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
Date
getTriggerDay
()
{
return
triggerDay
;
}
public
void
setTriggerDay
(
Date
triggerDay
)
{
this
.
triggerDay
=
triggerDay
;
}
public
int
getRunningCount
()
{
return
runningCount
;
}
public
void
setRunningCount
(
int
runningCount
)
{
this
.
runningCount
=
runningCount
;
}
public
int
getSucCount
()
{
return
sucCount
;
}
public
void
setSucCount
(
int
sucCount
)
{
this
.
sucCount
=
sucCount
;
}
public
int
getFailCount
()
{
return
failCount
;
}
public
void
setFailCount
(
int
failCount
)
{
this
.
failCount
=
failCount
;
}
}
xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java
浏览文件 @
7ab75aa8
package
com
.
xxl
.
job
.
admin
.
core
.
scheduler
;
package
com
.
xxl
.
job
.
admin
.
core
.
scheduler
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.thread.JobFailMonitorHelper
;
import
com.xxl.job.admin.core.thread.*
;
import
com.xxl.job.admin.core.thread.JobRegistryMonitorHelper
;
import
com.xxl.job.admin.core.thread.JobScheduleHelper
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
...
@@ -40,6 +37,9 @@ public class XxlJobScheduler {
...
@@ -40,6 +37,9 @@ public class XxlJobScheduler {
// admin trigger pool start
// admin trigger pool start
JobTriggerPoolHelper
.
toStart
();
JobTriggerPoolHelper
.
toStart
();
// admin log report start
JobLogReportHelper
.
getInstance
().
start
();
// start-schedule
// start-schedule
JobScheduleHelper
.
getInstance
().
start
();
JobScheduleHelper
.
getInstance
().
start
();
...
@@ -52,6 +52,9 @@ public class XxlJobScheduler {
...
@@ -52,6 +52,9 @@ public class XxlJobScheduler {
// stop-schedule
// stop-schedule
JobScheduleHelper
.
getInstance
().
toStop
();
JobScheduleHelper
.
getInstance
().
toStop
();
// admin log report stop
JobLogReportHelper
.
getInstance
().
toStop
();
// admin trigger pool stop
// admin trigger pool stop
JobTriggerPoolHelper
.
toStop
();
JobTriggerPoolHelper
.
toStop
();
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java
浏览文件 @
7ab75aa8
...
@@ -85,12 +85,20 @@ public class JobFailMonitorHelper {
...
@@ -85,12 +85,20 @@ public class JobFailMonitorHelper {
}
}
}
}
TimeUnit
.
SECONDS
.
sleep
(
10
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(!
toStop
)
{
if
(!
toStop
)
{
logger
.
error
(
">>>>>>>>>>> xxl-job, job fail monitor thread error:{}"
,
e
);
logger
.
error
(
">>>>>>>>>>> xxl-job, job fail monitor thread error:{}"
,
e
);
}
}
}
}
try
{
TimeUnit
.
SECONDS
.
sleep
(
10
);
}
catch
(
Exception
e
)
{
if
(!
toStop
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
logger
.
info
(
">>>>>>>>>>> xxl-job, job fail monitor thread stop"
);
logger
.
info
(
">>>>>>>>>>> xxl-job, job fail monitor thread stop"
);
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobLogReportHelper.java
0 → 100644
浏览文件 @
7ab75aa8
package
com
.
xxl
.
job
.
admin
.
core
.
thread
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.model.XxlJobLogReport
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
* job log report helper
*
* @author xuxueli 2019-11-22
*/
public
class
JobLogReportHelper
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
JobLogReportHelper
.
class
);
private
static
JobLogReportHelper
instance
=
new
JobLogReportHelper
();
public
static
JobLogReportHelper
getInstance
(){
return
instance
;
}
private
Thread
logrThread
;
private
volatile
boolean
toStop
=
false
;
public
void
start
(){
logrThread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
// monitor
while
(!
toStop
)
{
try
{
// refresh log report in 3 days
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
// today
Calendar
itemDay
=
Calendar
.
getInstance
();
itemDay
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
i
);
itemDay
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
itemDay
.
set
(
Calendar
.
MINUTE
,
0
);
itemDay
.
set
(
Calendar
.
SECOND
,
0
);
itemDay
.
set
(
Calendar
.
MILLISECOND
,
0
);
Date
todayFrom
=
itemDay
.
getTime
();
itemDay
.
set
(
Calendar
.
HOUR_OF_DAY
,
23
);
itemDay
.
set
(
Calendar
.
MINUTE
,
59
);
itemDay
.
set
(
Calendar
.
SECOND
,
59
);
itemDay
.
set
(
Calendar
.
MILLISECOND
,
999
);
Date
todayTo
=
itemDay
.
getTime
();
// refresh log-report every minute
XxlJobLogReport
xxlJobLogReport
=
new
XxlJobLogReport
();
xxlJobLogReport
.
setTriggerDay
(
todayFrom
);
xxlJobLogReport
.
setRunningCount
(
0
);
xxlJobLogReport
.
setSucCount
(
0
);
xxlJobLogReport
.
setFailCount
(
0
);
Map
<
String
,
Object
>
triggerCountMap
=
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobLogDao
().
findLogReport
(
todayFrom
,
todayTo
);
if
(
triggerCountMap
!=
null
&&
triggerCountMap
.
size
()>
0
)
{
int
triggerDayCount
=
triggerCountMap
.
containsKey
(
"triggerDayCount"
)?
Integer
.
valueOf
(
String
.
valueOf
(
triggerCountMap
.
get
(
"triggerDayCount"
))):
0
;
int
triggerDayCountRunning
=
triggerCountMap
.
containsKey
(
"triggerDayCountRunning"
)?
Integer
.
valueOf
(
String
.
valueOf
(
triggerCountMap
.
get
(
"triggerDayCountRunning"
))):
0
;
int
triggerDayCountSuc
=
triggerCountMap
.
containsKey
(
"triggerDayCountSuc"
)?
Integer
.
valueOf
(
String
.
valueOf
(
triggerCountMap
.
get
(
"triggerDayCountSuc"
))):
0
;
int
triggerDayCountFail
=
triggerDayCount
-
triggerDayCountRunning
-
triggerDayCountSuc
;
xxlJobLogReport
.
setRunningCount
(
triggerDayCountRunning
);
xxlJobLogReport
.
setSucCount
(
triggerDayCountSuc
);
xxlJobLogReport
.
setFailCount
(
triggerDayCountFail
);
}
// do refresh
int
ret
=
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobLogReportDao
().
update
(
xxlJobLogReport
);
if
(
ret
<
1
)
{
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobLogReportDao
().
save
(
xxlJobLogReport
);
}
}
}
catch
(
Exception
e
)
{
if
(!
toStop
)
{
logger
.
error
(
">>>>>>>>>>> xxl-job, job log report thread error:{}"
,
e
);
}
}
try
{
TimeUnit
.
MINUTES
.
sleep
(
1
);
}
catch
(
Exception
e
)
{
if
(!
toStop
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
logger
.
info
(
">>>>>>>>>>> xxl-job, job log report thread stop"
);
}
});
logrThread
.
setDaemon
(
true
);
logrThread
.
setName
(
"xxl-job, admin JobLogReportHelper"
);
logrThread
.
start
();
}
public
void
toStop
(){
toStop
=
true
;
// interrupt and wait
logrThread
.
interrupt
();
try
{
logrThread
.
join
();
}
catch
(
InterruptedException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java
浏览文件 @
7ab75aa8
...
@@ -84,6 +84,7 @@ public class JobScheduleHelper {
...
@@ -84,6 +84,7 @@ public class JobScheduleHelper {
// time-ring jump
// time-ring jump
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
()
+
PRE_READ_MS
)
{
if
(
nowTime
>
jobInfo
.
getTriggerNextTime
()
+
PRE_READ_MS
)
{
// 2.1、trigger-expire > 5s:pass && make next-trigger-time
// 2.1、trigger-expire > 5s:pass && make next-trigger-time
logger
.
warn
(
">>>>>>>>>>> xxl-job, schedule misfire, jobId = "
+
jobInfo
.
getId
());
// fresh next
// fresh next
refreshNextValidTime
(
jobInfo
,
new
Date
());
refreshNextValidTime
(
jobInfo
,
new
Date
());
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java
浏览文件 @
7ab75aa8
...
@@ -41,9 +41,7 @@ public interface XxlJobLogDao {
...
@@ -41,9 +41,7 @@ public interface XxlJobLogDao {
public
int
delete
(
@Param
(
"jobId"
)
int
jobId
);
public
int
delete
(
@Param
(
"jobId"
)
int
jobId
);
public
int
triggerCountByHandleCode
(
@Param
(
"handleCode"
)
int
handleCode
);
public
Map
<
String
,
Object
>
findLogReport
(
@Param
(
"from"
)
Date
from
,
public
List
<
Map
<
String
,
Object
>>
triggerCountByDay
(
@Param
(
"from"
)
Date
from
,
@Param
(
"to"
)
Date
to
);
@Param
(
"to"
)
Date
to
);
public
List
<
Long
>
findClearLogIds
(
@Param
(
"jobGroup"
)
int
jobGroup
,
public
List
<
Long
>
findClearLogIds
(
@Param
(
"jobGroup"
)
int
jobGroup
,
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogReportDao.java
0 → 100644
浏览文件 @
7ab75aa8
package
com
.
xxl
.
job
.
admin
.
dao
;
import
com.xxl.job.admin.core.model.XxlJobLogReport
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
/**
* job log
* @author xuxueli 2019-11-22
*/
@Mapper
public
interface
XxlJobLogReportDao
{
public
int
save
(
XxlJobLogReport
xxlJobLogReport
);
public
int
update
(
XxlJobLogReport
xxlJobLogReport
);
public
List
<
XxlJobLogReport
>
queryLogReport
(
@Param
(
"triggerDayFrom"
)
Date
triggerDayFrom
,
@Param
(
"triggerDayTo"
)
Date
triggerDayTo
);
public
XxlJobLogReport
queryLogReportTotal
();
}
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
浏览文件 @
7ab75aa8
...
@@ -3,13 +3,11 @@ package com.xxl.job.admin.service.impl;
...
@@ -3,13 +3,11 @@ package com.xxl.job.admin.service.impl;
import
com.xxl.job.admin.core.model.XxlJobGroup
;
import
com.xxl.job.admin.core.model.XxlJobGroup
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
com.xxl.job.admin.core.cron.CronExpression
;
import
com.xxl.job.admin.core.cron.CronExpression
;
import
com.xxl.job.admin.core.model.XxlJobLogReport
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.thread.JobScheduleHelper
;
import
com.xxl.job.admin.core.thread.JobScheduleHelper
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.dao.XxlJobGroupDao
;
import
com.xxl.job.admin.dao.*
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobLogGlueDao
;
import
com.xxl.job.admin.service.XxlJobService
;
import
com.xxl.job.admin.service.XxlJobService
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
...
@@ -40,6 +38,8 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -40,6 +38,8 @@ public class XxlJobServiceImpl implements XxlJobService {
public
XxlJobLogDao
xxlJobLogDao
;
public
XxlJobLogDao
xxlJobLogDao
;
@Resource
@Resource
private
XxlJobLogGlueDao
xxlJobLogGlueDao
;
private
XxlJobLogGlueDao
xxlJobLogGlueDao
;
@Resource
private
XxlJobLogReportDao
xxlJobLogReportDao
;
@Override
@Override
public
Map
<
String
,
Object
>
pageList
(
int
start
,
int
length
,
int
jobGroup
,
int
triggerStatus
,
String
jobDesc
,
String
executorHandler
,
String
author
)
{
public
Map
<
String
,
Object
>
pageList
(
int
start
,
int
length
,
int
jobGroup
,
int
triggerStatus
,
String
jobDesc
,
String
executorHandler
,
String
author
)
{
...
@@ -287,8 +287,13 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -287,8 +287,13 @@ public class XxlJobServiceImpl implements XxlJobService {
public
Map
<
String
,
Object
>
dashboardInfo
()
{
public
Map
<
String
,
Object
>
dashboardInfo
()
{
int
jobInfoCount
=
xxlJobInfoDao
.
findAllCount
();
int
jobInfoCount
=
xxlJobInfoDao
.
findAllCount
();
int
jobLogCount
=
xxlJobLogDao
.
triggerCountByHandleCode
(-
1
);
int
jobLogCount
=
0
;
int
jobLogSuccessCount
=
xxlJobLogDao
.
triggerCountByHandleCode
(
ReturnT
.
SUCCESS_CODE
);
int
jobLogSuccessCount
=
0
;
XxlJobLogReport
xxlJobLogReport
=
xxlJobLogReportDao
.
queryLogReportTotal
();
if
(
xxlJobLogReport
!=
null
)
{
jobLogCount
=
xxlJobLogReport
.
getRunningCount
()
+
xxlJobLogReport
.
getSucCount
()
+
xxlJobLogReport
.
getFailCount
();
jobLogSuccessCount
=
xxlJobLogReport
.
getSucCount
();
}
// executor count
// executor count
Set
<
String
>
executorAddressSet
=
new
HashSet
<
String
>();
Set
<
String
>
executorAddressSet
=
new
HashSet
<
String
>();
...
@@ -312,15 +317,8 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -312,15 +317,8 @@ public class XxlJobServiceImpl implements XxlJobService {
return
dashboardMap
;
return
dashboardMap
;
}
}
private
static
final
String
TRIGGER_CHART_DATA_CACHE
=
"trigger_chart_data_cache"
;
@Override
@Override
public
ReturnT
<
Map
<
String
,
Object
>>
chartInfo
(
Date
startDate
,
Date
endDate
)
{
public
ReturnT
<
Map
<
String
,
Object
>>
chartInfo
(
Date
startDate
,
Date
endDate
)
{
/*// get cache
String cacheKey = TRIGGER_CHART_DATA_CACHE + "_" + startDate.getTime() + "_" + endDate.getTime();
Map<String, Object> chartInfo = (Map<String, Object>) LocalCacheUtil.get(cacheKey);
if (chartInfo != null) {
return new ReturnT<Map<String, Object>>(chartInfo);
}*/
// process
// process
List
<
String
>
triggerDayList
=
new
ArrayList
<
String
>();
List
<
String
>
triggerDayList
=
new
ArrayList
<
String
>();
...
@@ -331,14 +329,14 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -331,14 +329,14 @@ public class XxlJobServiceImpl implements XxlJobService {
int
triggerCountSucTotal
=
0
;
int
triggerCountSucTotal
=
0
;
int
triggerCountFailTotal
=
0
;
int
triggerCountFailTotal
=
0
;
List
<
Map
<
String
,
Object
>>
triggerCountMapAll
=
xxlJobLogDao
.
triggerCountByDay
(
startDate
,
endDate
);
List
<
XxlJobLogReport
>
logReportList
=
xxlJobLogReportDao
.
queryLogReport
(
startDate
,
endDate
);
if
(
triggerCountMapAll
!=
null
&&
triggerCountMapAll
.
size
()>
0
)
{
for
(
Map
<
String
,
Object
>
item:
triggerCountMapAll
)
{
if
(
logReportList
!=
null
&&
logReportList
.
size
()>
0
)
{
String
day
=
String
.
valueOf
(
item
.
get
(
"triggerDay"
));
for
(
XxlJobLogReport
item:
logReportList
)
{
int
triggerDayCount
=
Integer
.
valueOf
(
String
.
valueOf
(
item
.
get
(
"triggerDayCount"
)
));
String
day
=
DateUtil
.
formatDate
(
item
.
getTriggerDay
(
));
int
triggerDayCountRunning
=
Integer
.
valueOf
(
String
.
valueOf
(
item
.
get
(
"triggerDayCountRunning"
))
);
int
triggerDayCountRunning
=
item
.
getRunningCount
(
);
int
triggerDayCountSuc
=
Integer
.
valueOf
(
String
.
valueOf
(
item
.
get
(
"triggerDayCountSuc"
))
);
int
triggerDayCountSuc
=
item
.
getSucCount
(
);
int
triggerDayCountFail
=
triggerDayCount
-
triggerDayCountRunning
-
triggerDayCountSuc
;
int
triggerDayCountFail
=
item
.
getFailCount
()
;
triggerDayList
.
add
(
day
);
triggerDayList
.
add
(
day
);
triggerDayCountRunningList
.
add
(
triggerDayCountRunning
);
triggerDayCountRunningList
.
add
(
triggerDayCountRunning
);
...
@@ -350,8 +348,8 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -350,8 +348,8 @@ public class XxlJobServiceImpl implements XxlJobService {
triggerCountFailTotal
+=
triggerDayCountFail
;
triggerCountFailTotal
+=
triggerDayCountFail
;
}
}
}
else
{
}
else
{
for
(
int
i
=
4
;
i
>
-
1
;
i
--
)
{
for
(
int
i
=
-
6
;
i
<=
0
;
i
++
)
{
triggerDayList
.
add
(
DateUtil
.
formatDate
(
DateUtil
.
addDays
(
new
Date
(),
-
i
)));
triggerDayList
.
add
(
DateUtil
.
formatDate
(
DateUtil
.
addDays
(
new
Date
(),
i
)));
triggerDayCountRunningList
.
add
(
0
);
triggerDayCountRunningList
.
add
(
0
);
triggerDayCountSucList
.
add
(
0
);
triggerDayCountSucList
.
add
(
0
);
triggerDayCountFailList
.
add
(
0
);
triggerDayCountFailList
.
add
(
0
);
...
@@ -368,9 +366,6 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -368,9 +366,6 @@ public class XxlJobServiceImpl implements XxlJobService {
result
.
put
(
"triggerCountSucTotal"
,
triggerCountSucTotal
);
result
.
put
(
"triggerCountSucTotal"
,
triggerCountSucTotal
);
result
.
put
(
"triggerCountFailTotal"
,
triggerCountFailTotal
);
result
.
put
(
"triggerCountFailTotal"
,
triggerCountFailTotal
);
/*// set cache
LocalCacheUtil.set(cacheKey, result, 60*1000); // cache 60s*/
return
new
ReturnT
<
Map
<
String
,
Object
>>(
result
);
return
new
ReturnT
<
Map
<
String
,
Object
>>(
result
);
}
}
...
...
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml
浏览文件 @
7ab75aa8
...
@@ -164,17 +164,7 @@
...
@@ -164,17 +164,7 @@
WHERE job_id = #{jobId}
WHERE job_id = #{jobId}
</delete>
</delete>
<select
id=
"triggerCountByHandleCode"
resultType=
"int"
>
<!--<select id="triggerCountByDay" resultType="java.util.Map" >
SELECT count(1)
FROM xxl_job_log AS t
<trim
prefix=
"WHERE"
prefixOverrides=
"AND | OR"
>
<if
test=
"handleCode gt 0"
>
AND t.handle_code = #{handleCode}
</if>
</trim>
</select>
<select
id=
"triggerCountByDay"
resultType=
"java.util.Map"
>
SELECT
SELECT
DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
COUNT(handle_code) triggerDayCount,
COUNT(handle_code) triggerDayCount,
...
@@ -184,6 +174,15 @@
...
@@ -184,6 +174,15 @@
WHERE trigger_time BETWEEN #{from} and #{to}
WHERE trigger_time BETWEEN #{from} and #{to}
GROUP BY triggerDay
GROUP BY triggerDay
ORDER BY triggerDay
ORDER BY triggerDay
</select>-->
<select
id=
"findLogReport"
resultType=
"java.util.Map"
>
SELECT
COUNT(handle_code) triggerDayCount,
SUM(CASE WHEN (trigger_code in (0, 200) and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
FROM xxl_job_log
WHERE trigger_time BETWEEN #{from} and #{to}
</select>
</select>
<select
id=
"findClearLogIds"
resultType=
"long"
>
<select
id=
"findClearLogIds"
resultType=
"long"
>
...
...
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogReportMapper.xml
0 → 100644
浏览文件 @
7ab75aa8
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxl.job.admin.dao.XxlJobLogReportDao"
>
<resultMap
id=
"XxlJobLogReport"
type=
"com.xxl.job.admin.core.model.XxlJobLogReport"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"trigger_day"
property=
"triggerDay"
/>
<result
column=
"running_count"
property=
"runningCount"
/>
<result
column=
"suc_count"
property=
"sucCount"
/>
<result
column=
"fail_count"
property=
"failCount"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
t.id,
t.trigger_day,
t.running_count,
t.suc_count,
t.fail_count
</sql>
<insert
id=
"save"
parameterType=
"com.xxl.job.admin.core.model.XxlJobLogReport"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
INSERT INTO xxl_job_log_report (
`trigger_day`,
`running_count`,
`suc_count`,
`fail_count`
) VALUES (
#{triggerDay},
#{runningCount},
#{sucCount},
#{failCount}
);
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>-->
</insert>
<update
id=
"update"
>
UPDATE xxl_job_log_report
SET `running_count` = #{runningCount},
`suc_count` = #{sucCount},
`fail_count` = #{failCount}
WHERE `trigger_day` = #{triggerDay}
</update>
<select
id=
"queryLogReport"
resultMap=
"XxlJobLogReport"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM xxl_job_log_report AS t
WHERE t.trigger_day between #{triggerDayFrom} and #{triggerDayTo}
ORDER BY t.trigger_day ASC
</select>
<select
id=
"queryLogReportTotal"
resultMap=
"XxlJobLogReport"
>
SELECT
SUM(running_count) running_count,
SUM(suc_count) suc_count,
SUM(fail_count) fail_count
FROM xxl_job_log_report AS t
</select>
</mapper>
\ No newline at end of file
xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobLogDaoTest.java
浏览文件 @
7ab75aa8
...
@@ -9,7 +9,6 @@ import org.springframework.test.context.junit4.SpringRunner;
...
@@ -9,7 +9,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
...
@@ -47,13 +46,10 @@ public class XxlJobLogDaoTest {
...
@@ -47,13 +46,10 @@ public class XxlJobLogDaoTest {
dto
=
xxlJobLogDao
.
load
(
log
.
getId
());
dto
=
xxlJobLogDao
.
load
(
log
.
getId
());
List
<
Map
<
String
,
Object
>>
list2
=
xxlJobLogDao
.
triggerCountByDay
(
new
Date
(
new
Date
().
getTime
()
+
30
*
24
*
60
*
60
*
1000
),
new
Date
());
List
<
Long
>
ret4
=
xxlJobLogDao
.
findClearLogIds
(
1
,
1
,
new
Date
(),
100
,
100
);
List
<
Long
>
ret4
=
xxlJobLogDao
.
findClearLogIds
(
1
,
1
,
new
Date
(),
100
,
100
);
int
ret2
=
xxlJobLogDao
.
delete
(
log
.
getJobId
());
int
ret2
=
xxlJobLogDao
.
delete
(
log
.
getJobId
());
int
ret3
=
xxlJobLogDao
.
triggerCountByHandleCode
(-
1
);
}
}
}
}
xxl-job-core/src/main/java/com/xxl/job/core/util/DateUtil.java
浏览文件 @
7ab75aa8
...
@@ -123,10 +123,6 @@ public class DateUtil {
...
@@ -123,10 +123,6 @@ public class DateUtil {
// ---------------------- add date ----------------------
// ---------------------- add date ----------------------
public
static
Date
addDays
(
final
Date
date
,
final
int
amount
)
{
return
add
(
date
,
Calendar
.
DAY_OF_MONTH
,
amount
);
}
public
static
Date
addYears
(
final
Date
date
,
final
int
amount
)
{
public
static
Date
addYears
(
final
Date
date
,
final
int
amount
)
{
return
add
(
date
,
Calendar
.
YEAR
,
amount
);
return
add
(
date
,
Calendar
.
YEAR
,
amount
);
}
}
...
@@ -135,6 +131,10 @@ public class DateUtil {
...
@@ -135,6 +131,10 @@ public class DateUtil {
return
add
(
date
,
Calendar
.
MONTH
,
amount
);
return
add
(
date
,
Calendar
.
MONTH
,
amount
);
}
}
public
static
Date
addDays
(
final
Date
date
,
final
int
amount
)
{
return
add
(
date
,
Calendar
.
DAY_OF_MONTH
,
amount
);
}
private
static
Date
add
(
final
Date
date
,
final
int
calendarField
,
final
int
amount
)
{
private
static
Date
add
(
final
Date
date
,
final
int
calendarField
,
final
int
amount
)
{
if
(
date
==
null
)
{
if
(
date
==
null
)
{
return
null
;
return
null
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论