v1.4
xueli.xue 9 years ago
parent 8b71e2cec4
commit c8b9403e83

@ -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, "调度失败,无法查看执行日志");
} }

@ -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

@ -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>';

@ -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 handlerThread = new JobThread(handler); JobThread jobThread = new JobThread(handler);
handlerThread.start(); jobThread.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, handlerThread); // putIfAbsent return HandlerRouter.JobThreadRepository.put(jobkey, jobThread); // putIfAbsent
} }
public static JobThread loadJobThread(String jobKey){ public static JobThread loadJobThread(String jobKey){
return HandlerRouter.JobThreadRepository.get(jobKey); return HandlerRouter.JobThreadRepository.get(jobKey);

@ -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 (jobThread == null) {
// jobhandler match
if (jobHandler==null) { if (jobHandler==null) {
return new ResponseModel(ResponseModel.FAIL, "job handler for jobKey=[" + jobKey + "] not found."); return new ResponseModel(ResponseModel.FAIL, "job handler for jobKey=[" + jobKey + "] not found.");
} }
if (jobThread == null) {
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 {
} }
} 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
if (jobThread == null) {
jobThread = HandlerRouter.loadJobThread(jobKey); jobThread = HandlerRouter.loadJobThread(jobKey);
}
// push data to queue // push data to queue
jobThread.pushTriggerQueue(requestModel); jobThread.pushTriggerQueue(requestModel);

@ -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{
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{
} 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{
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);
} }
} }

@ -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());
} }
} }

Loading…
Cancel
Save