Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
895ad80e
提交
895ad80e
authored
4月 11, 2020
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调度中心与执行器通讯规范为双向restful,方便跨语言,以及第三方执行器实现;通讯组件xxl-rpc方案调整为Jetty+Gson方案;
上级
c925bd16
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
114 行增加
和
17 行删除
+114
-17
XxlJobTrigger.java
...in/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java
+3
-3
jobinfo.index.1.js
...job-admin/src/main/resources/static/js/jobinfo.index.1.js
+3
-3
EmbedServer.java
...re/src/main/java/com/xxl/job/core/server/EmbedServer.java
+2
-2
TriggerCallbackThread.java
...n/java/com/xxl/job/core/thread/TriggerCallbackThread.java
+5
-5
FileUtil.java
...ob-core/src/main/java/com/xxl/job/core/util/FileUtil.java
+4
-4
JdkSerializeTool.java
...src/main/java/com/xxl/job/core/util/JdkSerializeTool.java
+73
-0
ThrowableUtil.java
...re/src/main/java/com/xxl/job/core/util/ThrowableUtil.java
+24
-0
没有找到文件。
xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java
浏览文件 @
895ad80e
package
com
.
xxl
.
job
.
admin
.
core
.
trigger
;
package
com
.
xxl
.
job
.
admin
.
core
.
trigger
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.scheduler.XxlJobScheduler
;
import
com.xxl.job.admin.core.model.XxlJobGroup
;
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.model.XxlJobLog
;
import
com.xxl.job.admin.core.model.XxlJobLog
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum
;
import
com.xxl.job.admin.core.scheduler.XxlJobScheduler
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.TriggerParam
;
import
com.xxl.job.core.biz.model.TriggerParam
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.util.IpUtil
;
import
com.xxl.job.core.util.IpUtil
;
import
io.netty.util.interna
l.ThrowableUtil
;
import
com.xxl.job.core.uti
l.ThrowableUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -211,7 +211,7 @@ public class XxlJobTrigger {
...
@@ -211,7 +211,7 @@ public class XxlJobTrigger {
runResult
=
executorBiz
.
run
(
triggerParam
);
runResult
=
executorBiz
.
run
(
triggerParam
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running."
,
address
,
e
);
logger
.
error
(
">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running."
,
address
,
e
);
runResult
=
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
ThrowableUtil
.
stackTraceT
oString
(
e
));
runResult
=
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
ThrowableUtil
.
t
oString
(
e
));
}
}
StringBuffer
runResultSB
=
new
StringBuffer
(
I18nUtil
.
getString
(
"jobconf_trigger_run"
)
+
":"
);
StringBuffer
runResultSB
=
new
StringBuffer
(
I18nUtil
.
getString
(
"jobconf_trigger_run"
)
+
":"
);
...
...
xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js
浏览文件 @
895ad80e
...
@@ -298,13 +298,13 @@ $(function() {
...
@@ -298,13 +298,13 @@ $(function() {
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
var
html
=
'<
center
>'
;
var
html
=
'<
div
>'
;
if
(
data
.
code
==
200
&&
data
.
content
.
registryList
)
{
if
(
data
.
code
==
200
&&
data
.
content
.
registryList
)
{
for
(
var
index
in
data
.
content
.
registryList
)
{
for
(
var
index
in
data
.
content
.
registryList
)
{
html
+=
'
<span class="badge bg-green" >'
+
data
.
content
.
registryList
[
index
]
+
'</span><br>'
;
html
+=
(
parseInt
(
index
)
+
1
)
+
'.
<span class="badge bg-green" >'
+
data
.
content
.
registryList
[
index
]
+
'</span><br>'
;
}
}
}
}
html
+=
'</
center
>'
;
html
+=
'</
div
>'
;
layer
.
open
({
layer
.
open
({
title
:
I18n
.
jobinfo_opt_registryinfo
,
title
:
I18n
.
jobinfo_opt_registryinfo
,
...
...
xxl-job-core/src/main/java/com/xxl/job/core/server/EmbedServer.java
浏览文件 @
895ad80e
...
@@ -7,6 +7,7 @@ import com.xxl.job.core.biz.model.ReturnT;
...
@@ -7,6 +7,7 @@ import com.xxl.job.core.biz.model.ReturnT;
import
com.xxl.job.core.biz.model.TriggerParam
;
import
com.xxl.job.core.biz.model.TriggerParam
;
import
com.xxl.job.core.thread.ExecutorRegistryThread
;
import
com.xxl.job.core.thread.ExecutorRegistryThread
;
import
com.xxl.job.core.util.GsonTool
;
import
com.xxl.job.core.util.GsonTool
;
import
com.xxl.job.core.util.ThrowableUtil
;
import
com.xxl.job.core.util.XxlJobRemotingUtil
;
import
com.xxl.job.core.util.XxlJobRemotingUtil
;
import
io.netty.bootstrap.ServerBootstrap
;
import
io.netty.bootstrap.ServerBootstrap
;
import
io.netty.buffer.Unpooled
;
import
io.netty.buffer.Unpooled
;
...
@@ -18,7 +19,6 @@ import io.netty.handler.codec.http.*;
...
@@ -18,7 +19,6 @@ import io.netty.handler.codec.http.*;
import
io.netty.handler.timeout.IdleStateEvent
;
import
io.netty.handler.timeout.IdleStateEvent
;
import
io.netty.handler.timeout.IdleStateHandler
;
import
io.netty.handler.timeout.IdleStateHandler
;
import
io.netty.util.CharsetUtil
;
import
io.netty.util.CharsetUtil
;
import
io.netty.util.internal.ThrowableUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -185,7 +185,7 @@ public class EmbedServer {
...
@@ -185,7 +185,7 @@ public class EmbedServer {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"request error:"
+
ThrowableUtil
.
stackTraceT
oString
(
e
));
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"request error:"
+
ThrowableUtil
.
t
oString
(
e
));
}
}
}
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/thread/TriggerCallbackThread.java
浏览文件 @
895ad80e
...
@@ -8,7 +8,7 @@ import com.xxl.job.core.executor.XxlJobExecutor;
...
@@ -8,7 +8,7 @@ import com.xxl.job.core.executor.XxlJobExecutor;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.util.FileUtil
;
import
com.xxl.job.core.util.FileUtil
;
import
com.xxl.job.core.util.
Gson
Tool
;
import
com.xxl.job.core.util.
JdkSerialize
Tool
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -205,7 +205,7 @@ public class TriggerCallbackThread {
...
@@ -205,7 +205,7 @@ public class TriggerCallbackThread {
}
}
// append file
// append file
String
callbackParamList_Str
=
GsonTool
.
toJson
(
callbackParamList
);
byte
[]
callbackParamList_bytes
=
JdkSerializeTool
.
serialize
(
callbackParamList
);
File
callbackLogFile
=
new
File
(
failCallbackFileName
.
replace
(
"{x}"
,
String
.
valueOf
(
System
.
currentTimeMillis
())));
File
callbackLogFile
=
new
File
(
failCallbackFileName
.
replace
(
"{x}"
,
String
.
valueOf
(
System
.
currentTimeMillis
())));
if
(
callbackLogFile
.
exists
())
{
if
(
callbackLogFile
.
exists
())
{
...
@@ -216,7 +216,7 @@ public class TriggerCallbackThread {
...
@@ -216,7 +216,7 @@ public class TriggerCallbackThread {
}
}
}
}
}
}
FileUtil
.
writeFileContent
(
callbackLogFile
,
callbackParamList_
Str
);
FileUtil
.
writeFileContent
(
callbackLogFile
,
callbackParamList_
bytes
);
}
}
private
void
retryFailCallbackFile
(){
private
void
retryFailCallbackFile
(){
...
@@ -235,8 +235,8 @@ public class TriggerCallbackThread {
...
@@ -235,8 +235,8 @@ public class TriggerCallbackThread {
// load and clear file, retry
// load and clear file, retry
for
(
File
callbaclLogFile:
callbackLogPath
.
listFiles
())
{
for
(
File
callbaclLogFile:
callbackLogPath
.
listFiles
())
{
String
callbackParamList_str
=
FileUtil
.
readFileContent
(
callbaclLogFile
);
byte
[]
callbackParamList_bytes
=
FileUtil
.
readFileContent
(
callbaclLogFile
);
List
<
HandleCallbackParam
>
callbackParamList
=
GsonTool
.
fromJsonList
(
callbackParamList_str
,
HandleCallbackParam
.
class
);
List
<
HandleCallbackParam
>
callbackParamList
=
(
List
<
HandleCallbackParam
>)
JdkSerializeTool
.
deserialize
(
callbackParamList_bytes
,
List
.
class
);
callbaclLogFile
.
delete
();
callbaclLogFile
.
delete
();
doCallback
(
callbackParamList
);
doCallback
(
callbackParamList
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/util/FileUtil.java
浏览文件 @
895ad80e
...
@@ -48,7 +48,7 @@ public class FileUtil {
...
@@ -48,7 +48,7 @@ public class FileUtil {
}
}
public
static
void
writeFileContent
(
File
file
,
String
data
)
{
public
static
void
writeFileContent
(
File
file
,
byte
[]
data
)
{
// file
// file
if
(!
file
.
exists
())
{
if
(!
file
.
exists
())
{
...
@@ -59,7 +59,7 @@ public class FileUtil {
...
@@ -59,7 +59,7 @@ public class FileUtil {
FileOutputStream
fos
=
null
;
FileOutputStream
fos
=
null
;
try
{
try
{
fos
=
new
FileOutputStream
(
file
);
fos
=
new
FileOutputStream
(
file
);
fos
.
write
(
data
.
getBytes
(
"utf-8"
)
);
fos
.
write
(
data
);
fos
.
flush
();
fos
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
...
@@ -75,7 +75,7 @@ public class FileUtil {
...
@@ -75,7 +75,7 @@ public class FileUtil {
}
}
public
static
String
readFileContent
(
File
file
)
{
public
static
byte
[]
readFileContent
(
File
file
)
{
Long
filelength
=
file
.
length
();
Long
filelength
=
file
.
length
();
byte
[]
filecontent
=
new
byte
[
filelength
.
intValue
()];
byte
[]
filecontent
=
new
byte
[
filelength
.
intValue
()];
...
@@ -85,7 +85,7 @@ public class FileUtil {
...
@@ -85,7 +85,7 @@ public class FileUtil {
in
.
read
(
filecontent
);
in
.
read
(
filecontent
);
in
.
close
();
in
.
close
();
return
new
String
(
filecontent
,
"utf-8"
)
;
return
filecontent
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
null
;
return
null
;
...
...
xxl-job-core/src/main/java/com/xxl/job/core/util/JdkSerializeTool.java
0 → 100644
浏览文件 @
895ad80e
package
com
.
xxl
.
job
.
core
.
util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.*
;
/**
* @author xuxueli 2020-04-12 0:14:00
*/
public
class
JdkSerializeTool
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
JdkSerializeTool
.
class
);
// ------------------------ serialize and unserialize ------------------------
/**
* 将对象-->byte[] (由于jedis中不支持直接存储object所以转换成byte[]存入)
*
* @param object
* @return
*/
public
static
byte
[]
serialize
(
Object
object
)
{
ObjectOutputStream
oos
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
{
// 序列化
baos
=
new
ByteArrayOutputStream
();
oos
=
new
ObjectOutputStream
(
baos
);
oos
.
writeObject
(
object
);
byte
[]
bytes
=
baos
.
toByteArray
();
return
bytes
;
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
try
{
oos
.
close
();
baos
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
null
;
}
/**
* 将byte[] -->Object
*
* @param bytes
* @return
*/
public
static
<
T
>
Object
deserialize
(
byte
[]
bytes
,
Class
<
T
>
clazz
)
{
ByteArrayInputStream
bais
=
null
;
try
{
// 反序列化
bais
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
bais
);
return
ois
.
readObject
();
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
try
{
bais
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
null
;
}
}
xxl-job-core/src/main/java/com/xxl/job/core/util/ThrowableUtil.java
0 → 100644
浏览文件 @
895ad80e
package
com
.
xxl
.
job
.
core
.
util
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
/**
* @author xuxueli 2018-10-20 20:07:26
*/
public
class
ThrowableUtil
{
/**
* parse error to string
*
* @param e
* @return
*/
public
static
String
toString
(
Throwable
e
)
{
StringWriter
stringWriter
=
new
StringWriter
();
e
.
printStackTrace
(
new
PrintWriter
(
stringWriter
));
String
errorMsg
=
stringWriter
.
toString
();
return
errorMsg
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论