Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
f83346de
提交
f83346de
authored
7月 28, 2017
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调度中心API服务,Client端调用逻辑优化
上级
8e07d501
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
16 行删除
+32
-16
XxlJobExecutor.java
...c/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
+28
-1
ExecutorRegistryThread.java
.../java/com/xxl/job/core/thread/ExecutorRegistryThread.java
+2
-9
TriggerCallbackThread.java
...n/java/com/xxl/job/core/thread/TriggerCallbackThread.java
+2
-6
没有找到文件。
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
浏览文件 @
f83346de
package
com
.
xxl
.
job
.
core
.
executor
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.impl.ExecutorBizImpl
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.annotation.JobHander
;
import
com.xxl.job.core.rpc.netcom.NetComClientProxy
;
import
com.xxl.job.core.rpc.netcom.NetComServerFactory
;
import
com.xxl.job.core.thread.ExecutorRegistryThread
;
import
com.xxl.job.core.thread.JobThread
;
...
...
@@ -17,6 +19,8 @@ import org.springframework.context.ApplicationEvent;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.event.ContextClosedEvent
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -29,7 +33,7 @@ public class XxlJobExecutor implements ApplicationContextAware, ApplicationListe
private
String
ip
;
private
int
port
=
9999
;
private
String
appName
;
p
ublic
static
String
adminAddresses
;
p
rivate
String
adminAddresses
;
public
static
String
logPath
;
public
void
setIp
(
String
ip
)
{
...
...
@@ -48,9 +52,32 @@ public class XxlJobExecutor implements ApplicationContextAware, ApplicationListe
this
.
logPath
=
logPath
;
}
// ---------------------------------- admin-client ------------------------------------
private
static
List
<
AdminBiz
>
adminBizList
;
private
static
void
initAdminBizList
(
String
adminAddresses
)
throws
Exception
{
if
(
adminAddresses
!=
null
&&
adminAddresses
.
trim
().
length
()>
0
)
{
for
(
String
address:
adminAddresses
.
trim
().
split
(
","
))
{
if
(
address
!=
null
&&
address
.
trim
().
length
()>
0
)
{
String
addressUrl
=
address
.
concat
(
"/api"
);
AdminBiz
adminBiz
=
(
AdminBiz
)
new
NetComClientProxy
(
AdminBiz
.
class
,
addressUrl
).
getObject
();
if
(
adminBizList
==
null
)
{
adminBizList
=
new
ArrayList
<
AdminBiz
>();
}
adminBizList
.
add
(
adminBiz
);
}
}
}
}
public
static
List
<
AdminBiz
>
getAdminBizList
(){
return
adminBizList
;
}
// ---------------------------------- job server ------------------------------------
private
NetComServerFactory
serverFactory
=
new
NetComServerFactory
();
public
void
start
()
throws
Exception
{
// init admin-client
initAdminBizList
(
adminAddresses
);
// executor start
NetComServerFactory
.
putService
(
ExecutorBiz
.
class
,
new
ExecutorBizImpl
());
// rpc-service, base on jetty
serverFactory
.
start
(
port
,
ip
,
appName
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/ExecutorRegistryThread.java
浏览文件 @
f83346de
...
...
@@ -5,7 +5,6 @@ import com.xxl.job.core.biz.model.RegistryParam;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.enums.RegistryConfig
;
import
com.xxl.job.core.executor.XxlJobExecutor
;
import
com.xxl.job.core.rpc.netcom.NetComClientProxy
;
import
com.xxl.job.core.util.IpUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -32,7 +31,7 @@ public class ExecutorRegistryThread extends Thread {
logger
.
warn
(
">>>>>>>>>>>> xxl-job, executor registry config fail, appName is null."
);
return
;
}
if
(
XxlJobExecutor
.
adminAddresses
==
null
||
XxlJobExecutor
.
adminAddresses
.
trim
().
length
()==
0
)
{
if
(
XxlJobExecutor
.
getAdminBizList
()
==
null
)
{
logger
.
warn
(
">>>>>>>>>>>> xxl-job, executor registry config fail, adminAddresses is null."
);
return
;
}
...
...
@@ -49,15 +48,10 @@ public class ExecutorRegistryThread extends Thread {
@Override
public
void
run
()
{
while
(!
toStop
)
{
try
{
RegistryParam
registryParam
=
new
RegistryParam
(
RegistryConfig
.
RegistType
.
EXECUTOR
.
name
(),
appName
,
executorAddress
);
for
(
String
addressUrl:
XxlJobExecutor
.
adminAddresses
.
split
(
","
))
{
String
apiUrl
=
addressUrl
.
concat
(
"/api"
);
for
(
AdminBiz
adminBiz:
XxlJobExecutor
.
getAdminBizList
())
{
try
{
AdminBiz
adminBiz
=
(
AdminBiz
)
new
NetComClientProxy
(
AdminBiz
.
class
,
apiUrl
).
getObject
();
ReturnT
<
String
>
registryResult
=
adminBiz
.
registry
(
registryParam
);
if
(
registryResult
!=
null
&&
ReturnT
.
SUCCESS_CODE
==
registryResult
.
getCode
())
{
registryResult
=
ReturnT
.
SUCCESS
;
...
...
@@ -71,7 +65,6 @@ public class ExecutorRegistryThread extends Thread {
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/TriggerCallbackThread.java
浏览文件 @
f83346de
...
...
@@ -4,7 +4,6 @@ import com.xxl.job.core.biz.AdminBiz;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.executor.XxlJobExecutor
;
import
com.xxl.job.core.rpc.netcom.NetComClientProxy
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -43,17 +42,14 @@ public class TriggerCallbackThread {
callbackParamList
.
add
(
callback
);
// valid
if
(
XxlJobExecutor
.
adminAddresses
==
null
||
XxlJobExecutor
.
adminAddresses
.
trim
().
length
()==
0
)
{
if
(
XxlJobExecutor
.
getAdminBizList
()==
null
)
{
logger
.
warn
(
">>>>>>>>>>>> xxl-job callback fail, adminAddresses is null, callbackParamList:{}"
,
callbackParamList
);
continue
;
}
// callback, will retry if error
for
(
String
addressUrl:
XxlJobExecutor
.
adminAddresses
.
split
(
","
))
{
String
apiUrl
=
addressUrl
.
concat
(
"/api"
);
for
(
AdminBiz
adminBiz:
XxlJobExecutor
.
getAdminBizList
())
{
try
{
AdminBiz
adminBiz
=
(
AdminBiz
)
new
NetComClientProxy
(
AdminBiz
.
class
,
apiUrl
).
getObject
();
ReturnT
<
String
>
callbackResult
=
adminBiz
.
callback
(
callbackParamList
);
if
(
callbackResult
!=
null
&&
ReturnT
.
SUCCESS_CODE
==
callbackResult
.
getCode
())
{
callbackResult
=
ReturnT
.
SUCCESS
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论