Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
xxl-job
提交
9325afea
X
xxl-job
项目概览
OpenDocCN
/
xxl-job
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
xxl-job
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9325afea
编写于
12月 22, 2017
作者:
许雪里
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复Log路径生成异常问题;
新增JobKey处理工具;
上级
2f2ed563
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
13 deletion
+41
-13
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/JobKeyUtil.java
...src/main/java/com/xxl/job/admin/core/util/JobKeyUtil.java
+21
-0
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
...ain/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
+4
-3
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
...ava/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
+7
-6
xxl-job-core/src/main/java/com/xxl/job/core/log/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
;
package
com.xxl.job.admin.core.util
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
org.apache.commons.lang.StringUtils
;
/**
/**
* job key util
* job key util
...
@@ -20,4 +21,24 @@ public class JobKeyUtil {
...
@@ -20,4 +21,24 @@ public class JobKeyUtil {
.
concat
(
"_"
).
concat
(
String
.
valueOf
(
xxlJobInfo
.
getId
()));
.
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;
...
@@ -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.model.XxlJobLog
;
import
com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler
;
import
com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler
;
import
com.xxl.job.admin.core.trigger.XxlJobTrigger
;
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.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
...
@@ -72,9 +73,9 @@ public class AdminBizImpl implements AdminBiz {
...
@@ -72,9 +73,9 @@ public class AdminBizImpl implements AdminBiz {
String
[]
childJobKeys
=
xxlJobInfo
.
getChildJobKey
().
split
(
","
);
String
[]
childJobKeys
=
xxlJobInfo
.
getChildJobKey
().
split
(
","
);
for
(
int
i
=
0
;
i
<
childJobKeys
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
childJobKeys
.
length
;
i
++)
{
String
[]
jobKeyArr
=
childJobKeys
[
i
].
split
(
"_"
);
int
childJobId
=
JobKeyUtil
.
parseJobId
(
childJobKeys
[
i
]
);
if
(
jobKeyArr
!=
null
&&
jobKeyArr
.
length
==
2
)
{
if
(
childJobId
>
0
)
{
ReturnT
<
String
>
triggerChildResult
=
xxlJobService
.
triggerJob
(
Integer
.
valueOf
(
jobKeyArr
[
1
])
);
ReturnT
<
String
>
triggerChildResult
=
xxlJobService
.
triggerJob
(
childJobId
);
// add msg
// add msg
callbackMsg
+=
MessageFormat
.
format
(
"{0}/{1} [JobKey={2}], 触发{3}, 触发备注: {4} <br>"
,
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;
...
@@ -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.model.XxlJobInfo
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler
;
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.XxlJobGroupDao
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
...
@@ -107,11 +108,11 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -107,11 +108,11 @@ public class XxlJobServiceImpl implements XxlJobService {
if
(
StringUtils
.
isNotBlank
(
jobInfo
.
getChildJobKey
()))
{
if
(
StringUtils
.
isNotBlank
(
jobInfo
.
getChildJobKey
()))
{
String
[]
childJobKeys
=
jobInfo
.
getChildJobKey
().
split
(
","
);
String
[]
childJobKeys
=
jobInfo
.
getChildJobKey
().
split
(
","
);
for
(
String
childJobKeyItem:
childJobKeys
)
{
for
(
String
childJobKeyItem:
childJobKeys
)
{
String
[]
childJobKeyArr
=
childJobKeyItem
.
split
(
"_"
);
int
childJobId
=
JobKeyUtil
.
parseJobId
(
childJobKeyItem
);
if
(
childJob
KeyArr
.
length
!=
2
)
{
if
(
childJob
Id
<=
0
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})格式错误"
,
childJobKeyItem
));
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
)
{
if
(
childJobInfo
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})无效"
,
childJobKeyItem
));
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})无效"
,
childJobKeyItem
));
}
}
...
@@ -170,11 +171,11 @@ public class XxlJobServiceImpl implements XxlJobService {
...
@@ -170,11 +171,11 @@ public class XxlJobServiceImpl implements XxlJobService {
if
(
StringUtils
.
isNotBlank
(
jobInfo
.
getChildJobKey
()))
{
if
(
StringUtils
.
isNotBlank
(
jobInfo
.
getChildJobKey
()))
{
String
[]
childJobKeys
=
jobInfo
.
getChildJobKey
().
split
(
","
);
String
[]
childJobKeys
=
jobInfo
.
getChildJobKey
().
split
(
","
);
for
(
String
childJobKeyItem:
childJobKeys
)
{
for
(
String
childJobKeyItem:
childJobKeys
)
{
String
[]
childJobKeyArr
=
childJobKeyItem
.
split
(
"_"
);
int
childJobId
=
JobKeyUtil
.
parseJobId
(
childJobKeyItem
);
if
(
childJob
KeyArr
.
length
!=
2
)
{
if
(
childJob
Id
<=
0
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})格式错误"
,
childJobKeyItem
));
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
)
{
if
(
childJobInfo
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
MessageFormat
.
format
(
"子任务Key({0})无效"
,
childJobKeyItem
));
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 {
...
@@ -53,11 +53,16 @@ public class XxlJobFileAppender {
* @return
* @return
*/
*/
public
static
String
makeLogFileName
(
Date
triggerDate
,
int
logId
)
{
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
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// avoid concurrent problem, can not be static
String
logFileName
=
getLogPath
()
File
logFilePath
=
new
File
(
getLogPath
(),
sdf
.
format
(
triggerDate
));
.
concat
(
"/"
)
if
(!
logFilePath
.
exists
())
{
.
concat
(
sdf
.
format
(
triggerDate
))
logFilePath
.
mkdir
();
}
// filePath/yyyy-MM-dd/9999.log
String
logFileName
=
logFilePath
.
getPath
()
.
concat
(
"/"
)
.
concat
(
"/"
)
.
concat
(
String
.
valueOf
(
logId
))
.
concat
(
String
.
valueOf
(
logId
))
.
concat
(
".log"
);
.
concat
(
".log"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录