Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
9325afea
提交
9325afea
authored
12月 22, 2017
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复Log路径生成异常问题;
新增JobKey处理工具;
上级
2f2ed563
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
41 行增加
和
13 行删除
+41
-13
JobKeyUtil.java
...src/main/java/com/xxl/job/admin/core/util/JobKeyUtil.java
+21
-0
AdminBizImpl.java
...ain/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
+4
-3
XxlJobServiceImpl.java
...ava/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
+7
-6
XxlJobFileAppender.java
...rc/main/java/com/xxl/job/core/log/XxlJobFileAppender.java
+9
-4
没有找到文件。
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/JobKeyUtil.java
浏览文件 @
9325afea
package
com
.
xxl
.
job
.
admin
.
core
.
util
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
org.apache.commons.lang.StringUtils
;
/**
* job key util
...
...
@@ -20,4 +21,24 @@ public class JobKeyUtil {
.
concat
(
"_"
).
concat
(
String
.
valueOf
(
xxlJobInfo
.
getId
()));
}
/**
* parse jobId from JobKey
*
* @param jobKey
* @return
*/
public
static
int
parseJobId
(
String
jobKey
){
if
(
jobKey
!=
null
&&
jobKey
.
trim
().
length
()>
0
)
{
String
[]
jobKeyArr
=
jobKey
.
split
(
"_"
);
if
(
jobKeyArr
.
length
==
2
)
{
String
jobIdStr
=
jobKeyArr
[
1
];
if
(
StringUtils
.
isNotBlank
(
jobIdStr
)
&&
StringUtils
.
isNumeric
(
jobIdStr
))
{
int
jobId
=
Integer
.
valueOf
(
jobIdStr
);
return
jobId
;
}
}
}
return
-
1
;
}
}
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
浏览文件 @
9325afea
...
...
@@ -5,6 +5,7 @@ import com.xxl.job.admin.core.model.XxlJobInfo;
import
com.xxl.job.admin.core.model.XxlJobLog
;
import
com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler
;
import
com.xxl.job.admin.core.trigger.XxlJobTrigger
;
import
com.xxl.job.admin.core.util.JobKeyUtil
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
...
...
@@ -72,9 +73,9 @@ public class AdminBizImpl implements AdminBiz {
String
[]
childJobKeys
=
xxlJobInfo
.
getChildJobKey
().
split
(
","
);
for
(
int
i
=
0
;
i
<
childJobKeys
.
length
;
i
++)
{
String
[]
jobKeyArr
=
childJobKeys
[
i
].
split
(
"_"
);
if
(
jobKeyArr
!=
null
&&
jobKeyArr
.
length
==
2
)
{
ReturnT
<
String
>
triggerChildResult
=
xxlJobService
.
triggerJob
(
Integer
.
valueOf
(
jobKeyArr
[
1
])
);
int
childJobId
=
JobKeyUtil
.
parseJobId
(
childJobKeys
[
i
]
);
if
(
childJobId
>
0
)
{
ReturnT
<
String
>
triggerChildResult
=
xxlJobService
.
triggerJob
(
childJobId
);
// add msg
callbackMsg
+=
MessageFormat
.
format
(
"{0}/{1} [JobKey={2}], 触发{3}, 触发备注: {4} <br>"
,
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
浏览文件 @
9325afea
...
...
@@ -5,6 +5,7 @@ import com.xxl.job.admin.core.model.XxlJobGroup;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler
;
import
com.xxl.job.admin.core.util.JobKeyUtil
;
import
com.xxl.job.admin.dao.XxlJobGroupDao
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
...
...
@@ -107,11 +108,11 @@ public class XxlJobServiceImpl implements XxlJobService {
if
(
StringUtils
.
isNotBlank
(
jobInfo
.
getChildJobKey
()))
{
String
[]
childJobKeys
=
jobInfo
.
getChildJobKey
().
split
(
","
);
for
(
String
childJobKeyItem:
childJobKeys
)
{
String
[]
childJobKeyArr
=
childJobKeyItem
.
split
(
"_"
);
if
(
childJob
KeyArr
.
length
!=
2
)
{
int
childJobId
=
JobKeyUtil
.
parseJobId
(
childJobKeyItem
);
if
(
childJob
Id
<=
0
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})格式错误"
,
childJobKeyItem
));
}
XxlJobInfo
childJobInfo
=
xxlJobInfoDao
.
loadById
(
Integer
.
valueOf
(
childJobKeyArr
[
1
])
);
XxlJobInfo
childJobInfo
=
xxlJobInfoDao
.
loadById
(
childJobId
);
if
(
childJobInfo
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})无效"
,
childJobKeyItem
));
}
...
...
@@ -170,11 +171,11 @@ public class XxlJobServiceImpl implements XxlJobService {
if
(
StringUtils
.
isNotBlank
(
jobInfo
.
getChildJobKey
()))
{
String
[]
childJobKeys
=
jobInfo
.
getChildJobKey
().
split
(
","
);
for
(
String
childJobKeyItem:
childJobKeys
)
{
String
[]
childJobKeyArr
=
childJobKeyItem
.
split
(
"_"
);
if
(
childJob
KeyArr
.
length
!=
2
)
{
int
childJobId
=
JobKeyUtil
.
parseJobId
(
childJobKeyItem
);
if
(
childJob
Id
<=
0
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})格式错误"
,
childJobKeyItem
));
}
XxlJobInfo
childJobInfo
=
xxlJobInfoDao
.
loadById
(
Integer
.
valueOf
(
childJobKeyArr
[
1
])
);
XxlJobInfo
childJobInfo
=
xxlJobInfoDao
.
loadById
(
childJobId
);
if
(
childJobInfo
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})无效"
,
childJobKeyItem
));
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java
浏览文件 @
9325afea
...
...
@@ -53,11 +53,16 @@ public class XxlJobFileAppender {
* @return
*/
public
static
String
makeLogFileName
(
Date
triggerDate
,
int
logId
)
{
// filePath/yyyy-MM-dd/9999.log
// filePath/yyyy-MM-dd
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// avoid concurrent problem, can not be static
String
logFileName
=
getLogPath
()
.
concat
(
"/"
)
.
concat
(
sdf
.
format
(
triggerDate
))
File
logFilePath
=
new
File
(
getLogPath
(),
sdf
.
format
(
triggerDate
));
if
(!
logFilePath
.
exists
())
{
logFilePath
.
mkdir
();
}
// filePath/yyyy-MM-dd/9999.log
String
logFileName
=
logFilePath
.
getPath
()
.
concat
(
"/"
)
.
concat
(
String
.
valueOf
(
logId
))
.
concat
(
".log"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论