Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c8b9403e
authored
Jul 22, 2016
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
coding
parent
8b71e2ce
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
25 deletions
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java
xxl-job-admin/src/main/resources/config.properties
xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js
xxl-job-core/src/main/java/com/xxl/job/core/router/HandlerRouter.java
xxl-job-core/src/main/java/com/xxl/job/core/router/action/RunAction.java
xxl-job-core/src/main/java/com/xxl/job/core/router/thread/JobThread.java
xxl-job-core/src/main/java/com/xxl/job/core/router/thread/TriggerCallbackThread.java
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java
View file @
c8b9403e
...
@@ -110,7 +110,7 @@ public class JobLogController {
...
@@ -110,7 +110,7 @@ public class JobLogController {
if
(
log
==
null
)
{
if
(
log
==
null
)
{
return
new
ReturnT
<
String
>(
500
,
"参数异常"
);
return
new
ReturnT
<
String
>(
500
,
"参数异常"
);
}
}
if
(!
ResponseModel
.
SUCCESS
.
equals
(
log
.
getTriggerStatus
(
)))
{
if
(!
(
ResponseModel
.
SUCCESS
.
equals
(
log
.
getTriggerStatus
())
||
StringUtils
.
isNotBlank
(
log
.
getHandleStatus
()
)))
{
return
new
ReturnT
<
String
>(
500
,
"调度失败,无法查看执行日志"
);
return
new
ReturnT
<
String
>(
500
,
"调度失败,无法查看执行日志"
);
}
}
...
...
xxl-job-admin/src/main/resources/config.properties
View file @
c8b9403e
...
@@ -4,7 +4,7 @@ mail.port=25
...
@@ -4,7 +4,7 @@ mail.port=25
mail.username
=
ovono802302@163.com
mail.username
=
ovono802302@163.com
mail.password
=
asdfzxcv
mail.password
=
asdfzxcv
mail.sendFrom
=
ovono802302@163.com
mail.sendFrom
=
ovono802302@163.com
mail.sendNick
=
《调度
平台
平台XXL-JOB》
mail.sendNick
=
《调度
调度
平台XXL-JOB》
# for login
# for login
login.username
=
admin
login.username
=
admin
...
...
xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js
View file @
c8b9403e
...
@@ -130,7 +130,7 @@ $(function() {
...
@@ -130,7 +130,7 @@ $(function() {
"render"
:
function
(
data
,
type
,
row
)
{
"render"
:
function
(
data
,
type
,
row
)
{
// better support expression or string, not function
// better support expression or string, not function
return
function
()
{
return
function
()
{
if
(
row
.
triggerStatus
==
'SUCCESS'
){
if
(
row
.
triggerStatus
==
'SUCCESS'
||
row
.
handleStatus
){
var
temp
=
'<a href="javascript:;" class="logDetail" _id="'
+
row
.
id
+
'">执行日志</a>'
;
var
temp
=
'<a href="javascript:;" class="logDetail" _id="'
+
row
.
id
+
'">执行日志</a>'
;
if
(
!
row
.
handleStatus
){
if
(
!
row
.
handleStatus
){
temp
+=
'<br><a href="javascript:;" class="logKill" _id="'
+
row
.
id
+
'">终止任务</a>'
;
temp
+=
'<br><a href="javascript:;" class="logKill" _id="'
+
row
.
id
+
'">终止任务</a>'
;
...
...
xxl-job-core/src/main/java/com/xxl/job/core/router/HandlerRouter.java
View file @
c8b9403e
...
@@ -37,10 +37,10 @@ public class HandlerRouter {
...
@@ -37,10 +37,10 @@ public class HandlerRouter {
*/
*/
private
static
ConcurrentHashMap
<
String
,
JobThread
>
JobThreadRepository
=
new
ConcurrentHashMap
<
String
,
JobThread
>();
private
static
ConcurrentHashMap
<
String
,
JobThread
>
JobThreadRepository
=
new
ConcurrentHashMap
<
String
,
JobThread
>();
public
static
JobThread
registJobThread
(
String
jobkey
,
IJobHandler
handler
){
public
static
JobThread
registJobThread
(
String
jobkey
,
IJobHandler
handler
){
JobThread
handler
Thread
=
new
JobThread
(
handler
);
JobThread
job
Thread
=
new
JobThread
(
handler
);
handler
Thread
.
start
();
job
Thread
.
start
();
logger
.
info
(
">>>>>>>>>>> xxl-job regist
handler
success, jobkey:{}, handler:{}"
,
new
Object
[]{
jobkey
,
handler
});
logger
.
info
(
">>>>>>>>>>> xxl-job regist
JobThread
success, jobkey:{}, handler:{}"
,
new
Object
[]{
jobkey
,
handler
});
return
HandlerRouter
.
JobThreadRepository
.
put
(
jobkey
,
handler
Thread
);
// putIfAbsent
return
HandlerRouter
.
JobThreadRepository
.
put
(
jobkey
,
job
Thread
);
// putIfAbsent
}
}
public
static
JobThread
loadJobThread
(
String
jobKey
){
public
static
JobThread
loadJobThread
(
String
jobKey
){
return
HandlerRouter
.
JobThreadRepository
.
get
(
jobKey
);
return
HandlerRouter
.
JobThreadRepository
.
get
(
jobKey
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/router/action/RunAction.java
View file @
c8b9403e
...
@@ -27,20 +27,17 @@ public class RunAction extends IAction {
...
@@ -27,20 +27,17 @@ public class RunAction extends IAction {
// handler instance
// handler instance
IJobHandler
jobHandler
=
HandlerRouter
.
loadJobHandler
(
requestModel
.
getExecutorHandler
());
IJobHandler
jobHandler
=
HandlerRouter
.
loadJobHandler
(
requestModel
.
getExecutorHandler
());
if
(
jobHandler
==
null
)
{
return
new
ResponseModel
(
ResponseModel
.
FAIL
,
"job handler for jobKey=["
+
jobKey
+
"] not found."
);
}
if
(
jobThread
==
null
)
{
if
(
jobThread
==
null
)
{
// jobhandler match
if
(
jobHandler
==
null
)
{
return
new
ResponseModel
(
ResponseModel
.
FAIL
,
"job handler for jobKey=["
+
jobKey
+
"] not found."
);
}
jobThread
=
HandlerRouter
.
registJobThread
(
jobKey
,
jobHandler
);
jobThread
=
HandlerRouter
.
registJobThread
(
jobKey
,
jobHandler
);
}
else
{
}
else
{
// job handler update, kill old job thread
// job handler update, kill old job thread
if
(
jobThread
.
getHandler
()
!=
jobHandler
)
{
if
(
jobThread
.
getHandler
()
!=
jobHandler
)
{
// kill old job thread
// kill old job thread
jobThread
.
toStop
(
"
人工手动终止
"
);
jobThread
.
toStop
(
"
更换任务模式或JobHandler,终止旧任务线程
"
);
jobThread
.
interrupt
();
jobThread
.
interrupt
();
// new thread, with new job handler
// new thread, with new job handler
...
@@ -49,14 +46,25 @@ public class RunAction extends IAction {
...
@@ -49,14 +46,25 @@ public class RunAction extends IAction {
}
}
}
else
{
}
else
{
// glue model
// glue model
if
(
jobThread
==
null
)
{
if
(
jobThread
==
null
)
{
jobThread
=
HandlerRouter
.
registJobThread
(
jobKey
,
new
GlueJobHandler
(
requestModel
.
getJobGroup
(),
requestModel
.
getJobName
()));
jobThread
=
HandlerRouter
.
registJobThread
(
jobKey
,
new
GlueJobHandler
(
requestModel
.
getJobGroup
(),
requestModel
.
getJobName
()));
}
else
{
// job handler update, kill old job thread
if
(!(
jobThread
.
getHandler
()
instanceof
GlueJobHandler
))
{
// kill old job thread
jobThread
.
toStop
(
"更换任务模式或JobHandler,终止旧任务线程"
);
jobThread
.
interrupt
();
// new thread, with new job handler
jobThread
=
HandlerRouter
.
registJobThread
(
jobKey
,
new
GlueJobHandler
(
requestModel
.
getJobGroup
(),
requestModel
.
getJobName
()));
}
}
}
}
}
// sometime, cmap.get can not return given value, i do not know why
// sometime, cmap.get can not return given value, i do not know why
jobThread
=
HandlerRouter
.
loadJobThread
(
jobKey
);
if
(
jobThread
==
null
)
{
jobThread
=
HandlerRouter
.
loadJobThread
(
jobKey
);
}
// push data to queue
// push data to queue
jobThread
.
pushTriggerQueue
(
requestModel
);
jobThread
.
pushTriggerQueue
(
requestModel
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/router/thread/JobThread.java
View file @
c8b9403e
...
@@ -4,7 +4,6 @@ import com.xxl.job.core.handler.IJobHandler;
...
@@ -4,7 +4,6 @@ import com.xxl.job.core.handler.IJobHandler;
import
com.xxl.job.core.handler.IJobHandler.JobHandleStatus
;
import
com.xxl.job.core.handler.IJobHandler.JobHandleStatus
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.router.model.RequestModel
;
import
com.xxl.job.core.router.model.RequestModel
;
import
com.xxl.job.core.util.XxlJobNetCommUtil
;
import
org.eclipse.jetty.util.ConcurrentHashSet
;
import
org.eclipse.jetty.util.ConcurrentHashSet
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -88,7 +87,7 @@ public class JobThread extends Thread{
...
@@ -88,7 +87,7 @@ public class JobThread extends Thread{
e
.
printStackTrace
(
new
PrintWriter
(
out
));
e
.
printStackTrace
(
new
PrintWriter
(
out
));
_msg
=
out
.
toString
();
_msg
=
out
.
toString
();
}
}
logger
.
info
(
"----------- xxl-job job handle end ----------- <br>: ExecutorParams:{}, Status:{}, Msg:{}"
,
logger
.
info
(
"----------- xxl-job job handle end ----------- <br>
Look
: ExecutorParams:{}, Status:{}, Msg:{}"
,
new
Object
[]{
handlerParams
,
_status
,
_msg
});
new
Object
[]{
handlerParams
,
_status
,
_msg
});
// callback handler info
// callback handler info
...
@@ -100,7 +99,7 @@ public class JobThread extends Thread{
...
@@ -100,7 +99,7 @@ public class JobThread extends Thread{
}
else
{
}
else
{
// is killed
// is killed
triggerDate
.
setStatus
(
JobHandleStatus
.
FAIL
.
name
());
triggerDate
.
setStatus
(
JobHandleStatus
.
FAIL
.
name
());
triggerDate
.
setMsg
(
stopReason
+
"
人工手动终止
[业务运行中,被强制终止]"
);
triggerDate
.
setMsg
(
stopReason
+
"
[业务运行中,被强制终止]"
);
TriggerCallbackThread
.
pushCallBack
(
triggerDate
);
TriggerCallbackThread
.
pushCallBack
(
triggerDate
);
}
}
}
}
...
@@ -114,12 +113,9 @@ public class JobThread extends Thread{
...
@@ -114,12 +113,9 @@ public class JobThread extends Thread{
RequestModel
triggerDate
=
triggerQueue
.
poll
();
RequestModel
triggerDate
=
triggerQueue
.
poll
();
if
(
triggerDate
!=
null
)
{
if
(
triggerDate
!=
null
)
{
// is killed
// is killed
RequestModel
callback
=
new
RequestModel
();
triggerDate
.
setStatus
(
JobHandleStatus
.
FAIL
.
name
());
callback
.
setLogAddress
(
XxlJobNetCommUtil
.
addressToUrl
(
triggerDate
.
getLogAddress
()));
triggerDate
.
setMsg
(
stopReason
+
" [任务尚未执行,在调度队列中被终止]"
);
callback
.
setLogId
(
triggerDate
.
getLogId
());
TriggerCallbackThread
.
pushCallBack
(
triggerDate
);
callback
.
setStatus
(
JobHandleStatus
.
FAIL
.
name
());
callback
.
setMsg
(
stopReason
+
"[任务尚未执行,在调度队列中被终止]"
);
TriggerCallbackThread
.
pushCallBack
(
callback
);
}
}
}
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/router/thread/TriggerCallbackThread.java
View file @
c8b9403e
...
@@ -39,6 +39,7 @@ public class TriggerCallbackThread {
...
@@ -39,6 +39,7 @@ public class TriggerCallbackThread {
}
}
public
static
void
pushCallBack
(
RequestModel
callback
){
public
static
void
pushCallBack
(
RequestModel
callback
){
callBackQueue
.
add
(
callback
);
callBackQueue
.
add
(
callback
);
logger
.
debug
(
">>>>>>>>>>> xxl-job, push callback request, logId:{}"
,
callback
.
getLogId
());
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment