Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
粉色的八爪鱼
xxl-job
提交
ee9eca0d
X
xxl-job
项目概览
粉色的八爪鱼
/
xxl-job
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
ee9eca0d
编写于
3月 12, 2016
作者:
X
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
远程调度增强校验:1、调度中心与执行器时间偏移超过60秒拒绝任务执行;2、执行器校验调度uuid避免一次调度重复执行;
上级
53fd312d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
4 deletion
+20
-4
xxl-job-admin/src/main/java/com/xxl/job/service/job/RemoteHttpJobBean.java
.../main/java/com/xxl/job/service/job/RemoteHttpJobBean.java
+1
-0
xxl-job-client/src/main/java/com/xxl/job/client/handler/HandlerRepository.java
...in/java/com/xxl/job/client/handler/HandlerRepository.java
+8
-0
xxl-job-client/src/main/java/com/xxl/job/client/handler/HandlerThread.java
...c/main/java/com/xxl/job/client/handler/HandlerThread.java
+11
-4
未找到文件。
xxl-job-admin/src/main/java/com/xxl/job/service/job/RemoteHttpJobBean.java
浏览文件 @
ee9eca0d
...
...
@@ -57,6 +57,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
HashMap
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
HandlerRepository
.
TRIGGER_LOG_URL
,
PropertiesUtil
.
getString
(
HandlerRepository
.
TRIGGER_LOG_URL
));
params
.
put
(
HandlerRepository
.
TRIGGER_LOG_ID
,
String
.
valueOf
(
jobLog
.
getId
()));
params
.
put
(
HandlerRepository
.
TRIGGER_TIMESTAMP
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
params
.
put
(
HandlerRepository
.
HANDLER_NAME
,
jobDataMap
.
get
(
HandlerRepository
.
HANDLER_NAME
));
params
.
put
(
HandlerRepository
.
HANDLER_PARAMS
,
jobDataMap
.
get
(
HandlerRepository
.
HANDLER_PARAMS
));
...
...
xxl-job-client/src/main/java/com/xxl/job/client/handler/HandlerRepository.java
浏览文件 @
ee9eca0d
...
...
@@ -22,6 +22,7 @@ public class HandlerRepository {
public
static
final
String
TRIGGER_LOG_ID
=
"trigger_log_id"
;
public
static
final
String
TRIGGER_LOG_URL
=
"trigger_log_url"
;
public
static
final
String
TRIGGER_TIMESTAMP
=
"trigger_timestamp"
;
public
static
ConcurrentHashMap
<
String
,
HandlerThread
>
handlerTreadMap
=
new
ConcurrentHashMap
<
String
,
HandlerThread
>();
...
...
@@ -41,6 +42,13 @@ public class HandlerRepository {
RemoteCallBack
callback
=
new
RemoteCallBack
();
callback
.
setStatus
(
RemoteCallBack
.
FAIL
);
// encryption check
long
timestamp
=
_param
.
get
(
HandlerRepository
.
TRIGGER_TIMESTAMP
)!=
null
?
Long
.
valueOf
(
_param
.
get
(
HandlerRepository
.
TRIGGER_TIMESTAMP
)):-
1
;
if
(
System
.
currentTimeMillis
()
-
timestamp
>
60000
)
{
callback
.
setMsg
(
"Timestamp check failed."
);
return
JacksonUtil
.
writeValueAsString
(
callback
);
}
// push data to queue
String
handler_name
=
_param
.
get
(
HandlerRepository
.
HANDLER_NAME
);
if
(
handler_name
!=
null
&&
handler_name
.
trim
().
length
()>
0
)
{
...
...
xxl-job-client/src/main/java/com/xxl/job/client/handler/HandlerThread.java
浏览文件 @
ee9eca0d
...
...
@@ -7,6 +7,7 @@ import java.util.Map;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.eclipse.jetty.util.ConcurrentHashSet
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -23,14 +24,18 @@ public class HandlerThread extends Thread{
private
IJobHandler
handler
;
private
LinkedBlockingQueue
<
Map
<
String
,
String
>>
handlerDataQueue
;
private
ConcurrentHashSet
<
String
>
logIdSet
;
// avoid repeat trigger for the same TRIGGER_LOG_ID
public
HandlerThread
(
IJobHandler
handler
)
{
this
.
handler
=
handler
;
handlerDataQueue
=
new
LinkedBlockingQueue
<
Map
<
String
,
String
>>();
logIdSet
=
new
ConcurrentHashSet
<
String
>();
}
public
void
pushData
(
Map
<
String
,
String
>
param
)
{
handlerDataQueue
.
offer
(
param
);
if
(
param
.
get
(
HandlerRepository
.
TRIGGER_LOG_ID
)!=
null
&&
!
logIdSet
.
contains
(
param
.
get
(
HandlerRepository
.
TRIGGER_LOG_ID
)))
{
handlerDataQueue
.
offer
(
param
);
}
}
int
i
=
1
;
...
...
@@ -38,12 +43,13 @@ public class HandlerThread extends Thread{
public
void
run
()
{
while
(
true
){
try
{
i
++;
Map
<
String
,
String
>
handlerData
=
handlerDataQueue
.
poll
();
if
(
handlerData
!=
null
)
{
i
=
0
;
String
trigger_log_url
=
handlerData
.
get
(
HandlerRepository
.
TRIGGER_LOG_URL
);
String
trigger_log_id
=
handlerData
.
get
(
HandlerRepository
.
TRIGGER_LOG_ID
);
String
handler_params
=
handlerData
.
get
(
HandlerRepository
.
HANDLER_PARAMS
);
logIdSet
.
remove
(
trigger_log_id
);
// parse param
String
[]
handlerParams
=
null
;
...
...
@@ -68,9 +74,8 @@ public class HandlerThread extends Thread{
// callback handler info
RemoteCallBack
callback
=
null
;
try
{
HashMap
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
HandlerRepository
.
TRIGGER_LOG_ID
,
trigger_log_id
);
params
.
put
(
"trigger_log_id"
,
trigger_log_id
);
params
.
put
(
"status"
,
_status
.
name
());
params
.
put
(
"msg"
,
_msg
);
callback
=
HttpUtil
.
post
(
trigger_log_url
,
params
);
...
...
@@ -80,6 +85,8 @@ public class HandlerThread extends Thread{
logger
.
info
(
"<<<<<<<<<<< xxl-job thread handle, handlerData:{}, callback_status:{}, callback_msg:{}, callback:{}, thread:{}"
,
new
Object
[]{
handlerData
,
_status
,
_msg
,
callback
,
this
});
}
else
{
i
++;
logIdSet
.
clear
();
try
{
TimeUnit
.
MILLISECONDS
.
sleep
(
i
*
100
);
}
catch
(
InterruptedException
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录