Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
f7fa7216
提交
f7fa7216
authored
8月 18, 2021
作者:
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code optimize
上级
8e102f8c
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
78 行增加
和
80 行删除
+78
-80
EmailJobAlarm.java
...java/com/xxl/job/admin/core/alarm/impl/EmailJobAlarm.java
+1
-0
XxlJobExecutor.java
...c/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
+57
-48
XxlJobSimpleExecutor.java
.../com/xxl/job/core/executor/impl/XxlJobSimpleExecutor.java
+4
-1
XxlJobSpringExecutor.java
.../com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java
+3
-2
ExecutorRegistryThread.java
.../java/com/xxl/job/core/thread/ExecutorRegistryThread.java
+1
-1
JobLogFileCleanThread.java
...n/java/com/xxl/job/core/thread/JobLogFileCleanThread.java
+1
-1
TriggerCallbackThread.java
...n/java/com/xxl/job/core/thread/TriggerCallbackThread.java
+2
-2
XxlJobRemotingUtil.java
...c/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java
+4
-0
FramelessApplication.java
...l/job/executor/sample/frameless/FramelessApplication.java
+2
-2
FrameLessXxlJobConfig.java
...ecutor/sample/frameless/config/FrameLessXxlJobConfig.java
+2
-2
SampleXxlJob.java
...ob/executor/sample/frameless/jobhandler/SampleXxlJob.java
+1
-1
SampleXxlJob.java
...com/xxl/job/executor/service/jobhandler/SampleXxlJob.java
+0
-20
没有找到文件。
xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/impl/EmailJobAlarm.java
浏览文件 @
f7fa7216
...
...
@@ -32,6 +32,7 @@ public class EmailJobAlarm implements JobAlarm {
*
* @param jobLog
*/
@Override
public
boolean
doAlarm
(
XxlJobInfo
info
,
XxlJobLog
jobLog
){
boolean
alarmResult
=
true
;
...
...
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
浏览文件 @
f7fa7216
...
...
@@ -84,10 +84,10 @@ public class XxlJobExecutor {
initEmbedServer
(
address
,
ip
,
port
,
appname
,
accessToken
);
}
public
void
destroy
(){
// dest
or
y executor-server
// dest
ro
y executor-server
stopEmbedServer
();
// dest
or
y jobThreadRepository
// dest
ro
y jobThreadRepository
if
(
jobThreadRepository
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
Integer
,
JobThread
>
item:
jobThreadRepository
.
entrySet
())
{
JobThread
oldJobThread
=
removeJobThread
(
item
.
getKey
(),
"web container destroy and kill the job."
);
...
...
@@ -105,58 +105,14 @@ public class XxlJobExecutor {
jobHandlerRepository
.
clear
();
// dest
or
y JobLogFileCleanThread
// dest
ro
y JobLogFileCleanThread
JobLogFileCleanThread
.
getInstance
().
toStop
();
// dest
or
y TriggerCallbackThread
// dest
ro
y TriggerCallbackThread
TriggerCallbackThread
.
getInstance
().
toStop
();
}
protected
void
registerJobHandler
(
XxlJob
xxlJob
,
Object
bean
,
Method
executeMethod
){
if
(
xxlJob
==
null
)
{
return
;
}
String
name
=
xxlJob
.
value
();
//make and simplify the variables since they'll be called several times later
Class
<?>
clazz
=
bean
.
getClass
();
String
methodName
=
executeMethod
.
getName
();
if
(
name
.
trim
().
length
()
==
0
)
{
throw
new
RuntimeException
(
"xxl-job method-jobhandler name invalid, for["
+
clazz
+
"#"
+
methodName
+
"] ."
);
}
if
(
loadJobHandler
(
name
)
!=
null
)
{
throw
new
RuntimeException
(
"xxl-job jobhandler["
+
name
+
"] naming conflicts."
);
}
executeMethod
.
setAccessible
(
true
);
// init and destroy
Method
initMethod
=
null
;
Method
destroyMethod
=
null
;
if
(
xxlJob
.
init
().
trim
().
length
()
>
0
)
{
try
{
initMethod
=
clazz
.
getDeclaredMethod
(
xxlJob
.
init
());
initMethod
.
setAccessible
(
true
);
}
catch
(
NoSuchMethodException
e
)
{
throw
new
RuntimeException
(
"xxl-job method-jobhandler initMethod invalid, for["
+
clazz
+
"#"
+
methodName
+
"] ."
);
}
}
if
(
xxlJob
.
destroy
().
trim
().
length
()
>
0
)
{
try
{
destroyMethod
=
clazz
.
getDeclaredMethod
(
xxlJob
.
destroy
());
destroyMethod
.
setAccessible
(
true
);
}
catch
(
NoSuchMethodException
e
)
{
throw
new
RuntimeException
(
"xxl-job method-jobhandler destroyMethod invalid, for["
+
clazz
+
"#"
+
methodName
+
"] ."
);
}
}
// registry jobhandler
registJobHandler
(
name
,
new
MethodJobHandler
(
bean
,
executeMethod
,
initMethod
,
destroyMethod
));
}
// ---------------------- admin-client (rpc invoker) ----------------------
private
static
List
<
AdminBiz
>
adminBizList
;
...
...
@@ -225,6 +181,59 @@ public class XxlJobExecutor {
logger
.
info
(
">>>>>>>>>>> xxl-job register jobhandler success, name:{}, jobHandler:{}"
,
name
,
jobHandler
);
return
jobHandlerRepository
.
put
(
name
,
jobHandler
);
}
protected
void
registJobHandler
(
XxlJob
xxlJob
,
Object
bean
,
Method
executeMethod
){
if
(
xxlJob
==
null
)
{
return
;
}
String
name
=
xxlJob
.
value
();
//make and simplify the variables since they'll be called several times later
Class
<?>
clazz
=
bean
.
getClass
();
String
methodName
=
executeMethod
.
getName
();
if
(
name
.
trim
().
length
()
==
0
)
{
throw
new
RuntimeException
(
"xxl-job method-jobhandler name invalid, for["
+
clazz
+
"#"
+
methodName
+
"] ."
);
}
if
(
loadJobHandler
(
name
)
!=
null
)
{
throw
new
RuntimeException
(
"xxl-job jobhandler["
+
name
+
"] naming conflicts."
);
}
// execute method
/*if (!(method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(String.class))) {
throw new RuntimeException("xxl-job method-jobhandler param-classtype invalid, for[" + bean.getClass() + "#" + method.getName() + "] , " +
"The correct method format like \" public ReturnT<String> execute(String param) \" .");
}
if (!method.getReturnType().isAssignableFrom(ReturnT.class)) {
throw new RuntimeException("xxl-job method-jobhandler return-classtype invalid, for[" + bean.getClass() + "#" + method.getName() + "] , " +
"The correct method format like \" public ReturnT<String> execute(String param) \" .");
}*/
executeMethod
.
setAccessible
(
true
);
// init and destroy
Method
initMethod
=
null
;
Method
destroyMethod
=
null
;
if
(
xxlJob
.
init
().
trim
().
length
()
>
0
)
{
try
{
initMethod
=
clazz
.
getDeclaredMethod
(
xxlJob
.
init
());
initMethod
.
setAccessible
(
true
);
}
catch
(
NoSuchMethodException
e
)
{
throw
new
RuntimeException
(
"xxl-job method-jobhandler initMethod invalid, for["
+
clazz
+
"#"
+
methodName
+
"] ."
);
}
}
if
(
xxlJob
.
destroy
().
trim
().
length
()
>
0
)
{
try
{
destroyMethod
=
clazz
.
getDeclaredMethod
(
xxlJob
.
destroy
());
destroyMethod
.
setAccessible
(
true
);
}
catch
(
NoSuchMethodException
e
)
{
throw
new
RuntimeException
(
"xxl-job method-jobhandler destroyMethod invalid, for["
+
clazz
+
"#"
+
methodName
+
"] ."
);
}
}
// registry jobhandler
registJobHandler
(
name
,
new
MethodJobHandler
(
bean
,
executeMethod
,
initMethod
,
destroyMethod
));
}
// ---------------------- job thread repository ----------------------
...
...
xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSimpleExecutor.java
浏览文件 @
f7fa7216
...
...
@@ -30,6 +30,7 @@ public class XxlJobSimpleExecutor extends XxlJobExecutor {
}
@Override
public
void
start
()
{
// init JobHandler Repository (for method)
...
...
@@ -43,6 +44,7 @@ public class XxlJobSimpleExecutor extends XxlJobExecutor {
}
}
@Override
public
void
destroy
()
{
super
.
destroy
();
}
...
...
@@ -62,7 +64,8 @@ public class XxlJobSimpleExecutor extends XxlJobExecutor {
}
for
(
Method
executeMethod
:
methods
)
{
XxlJob
xxlJob
=
executeMethod
.
getAnnotation
(
XxlJob
.
class
);
registerJobHandler
(
xxlJob
,
bean
,
executeMethod
);
// registry
registJobHandler
(
xxlJob
,
bean
,
executeMethod
);
}
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java
浏览文件 @
f7fa7216
...
...
@@ -105,7 +105,8 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC
for
(
Map
.
Entry
<
Method
,
XxlJob
>
methodXxlJobEntry
:
annotatedMethods
.
entrySet
())
{
Method
executeMethod
=
methodXxlJobEntry
.
getKey
();
XxlJob
xxlJob
=
methodXxlJobEntry
.
getValue
();
registerJobHandler
(
xxlJob
,
bean
,
executeMethod
);
// regist
registJobHandler
(
xxlJob
,
bean
,
executeMethod
);
}
}
}
...
...
@@ -115,7 +116,7 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
XxlJobSpringExecutor
.
applicationContext
=
applicationContext
;
}
public
static
ApplicationContext
getApplicationContext
()
{
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/ExecutorRegistryThread.java
浏览文件 @
f7fa7216
...
...
@@ -102,7 +102,7 @@ public class ExecutorRegistryThread {
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
logger
.
info
(
">>>>>>>>>>> xxl-job, executor registry thread dest
or
y."
);
logger
.
info
(
">>>>>>>>>>> xxl-job, executor registry thread dest
ro
y."
);
}
});
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/JobLogFileCleanThread.java
浏览文件 @
f7fa7216
...
...
@@ -96,7 +96,7 @@ public class JobLogFileCleanThread {
}
}
}
logger
.
info
(
">>>>>>>>>>> xxl-job, executor JobLogFileCleanThread thread dest
or
y."
);
logger
.
info
(
">>>>>>>>>>> xxl-job, executor JobLogFileCleanThread thread dest
ro
y."
);
}
});
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/TriggerCallbackThread.java
浏览文件 @
f7fa7216
...
...
@@ -95,7 +95,7 @@ public class TriggerCallbackThread {
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
logger
.
info
(
">>>>>>>>>>> xxl-job, executor callback thread dest
or
y."
);
logger
.
info
(
">>>>>>>>>>> xxl-job, executor callback thread dest
ro
y."
);
}
});
...
...
@@ -125,7 +125,7 @@ public class TriggerCallbackThread {
}
}
}
logger
.
info
(
">>>>>>>>>>> xxl-job, executor retry callback thread dest
or
y."
);
logger
.
info
(
">>>>>>>>>>> xxl-job, executor retry callback thread dest
ro
y."
);
}
});
triggerRetryCallbackThread
.
setDaemon
(
true
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java
浏览文件 @
f7fa7216
...
...
@@ -34,17 +34,21 @@ public class XxlJobRemotingUtil {
logger
.
error
(
e
.
getMessage
(),
e
);
}
connection
.
setHostnameVerifier
(
new
HostnameVerifier
()
{
@Override
public
boolean
verify
(
String
hostname
,
SSLSession
session
)
{
return
true
;
}
});
}
private
static
final
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]{
new
X509TrustManager
()
{
@Override
public
java
.
security
.
cert
.
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
java
.
security
.
cert
.
X509Certificate
[]{};
}
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
}};
...
...
xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/FramelessApplication.java
浏览文件 @
f7fa7216
...
...
@@ -29,8 +29,8 @@ public class FramelessApplication {
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
// dest
or
y
FrameLessXxlJobConfig
.
getInstance
().
dest
or
yXxlJobExecutor
();
// dest
ro
y
FrameLessXxlJobConfig
.
getInstance
().
dest
ro
yXxlJobExecutor
();
}
}
...
...
xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/config/FrameLessXxlJobConfig.java
浏览文件 @
f7fa7216
...
...
@@ -56,9 +56,9 @@ public class FrameLessXxlJobConfig {
}
/**
* dest
or
y
* dest
ro
y
*/
public
void
dest
or
yXxlJobExecutor
()
{
public
void
dest
ro
yXxlJobExecutor
()
{
if
(
xxlJobExecutor
!=
null
)
{
xxlJobExecutor
.
destroy
();
}
...
...
xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/jobhandler/SampleXxlJob.java
浏览文件 @
f7fa7216
...
...
@@ -244,7 +244,7 @@ public class SampleXxlJob {
logger
.
info
(
"init"
);
}
public
void
destroy
(){
logger
.
info
(
"dest
or
y"
);
logger
.
info
(
"dest
ro
y"
);
}
...
...
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java
浏览文件 @
f7fa7216
...
...
@@ -245,29 +245,9 @@ public class SampleXxlJob {
public
void
init
(){
logger
.
info
(
"init"
);
}
public
void
destroy
(){
logger
.
info
(
"destroy"
);
}
/**
* 6、生命周期任务示例:任务初始化与销毁时,支持private方法(但不推荐);
*/
@XxlJob
(
value
=
"demoJobHandler3"
,
init
=
"initForDemoJobHandler3"
,
destroy
=
"destroyForDemoJobHandler3"
)
public
void
demoJobHandler3
()
throws
Exception
{
XxlJobHelper
.
log
(
"XXL-JOB, Hello World."
);
}
private
void
initForDemoJobHandler3
(){
logger
.
info
(
"initForDemoJobHandler3"
);
}
/**
* 演示private方法也可以被访问且执行
*/
public
void
destroyForDemoJobHandler3
(){
logger
.
info
(
"destroyForDemoJobHandler3"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论