coding
This commit is contained in:
parent
8b71e2cec4
commit
c8b9403e83
|
@ -110,7 +110,7 @@ public class JobLogController {
|
|||
if (log == null) {
|
||||
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, "调度失败,无法查看执行日志");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ mail.port=25
|
|||
mail.username=ovono802302@163.com
|
||||
mail.password=asdfzxcv
|
||||
mail.sendFrom=ovono802302@163.com
|
||||
mail.sendNick=《调度平台平台XXL-JOB》
|
||||
mail.sendNick=《调度调度平台XXL-JOB》
|
||||
|
||||
# for login
|
||||
login.username=admin
|
||||
|
|
|
@ -130,7 +130,7 @@ $(function() {
|
|||
"render": function ( data, type, row ) {
|
||||
// better support expression or string, not function
|
||||
return function () {
|
||||
if (row.triggerStatus == 'SUCCESS'){
|
||||
if (row.triggerStatus == 'SUCCESS' || row.handleStatus){
|
||||
var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">执行日志</a>';
|
||||
if(!row.handleStatus){
|
||||
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>();
|
||||
public static JobThread registJobThread(String jobkey, IJobHandler handler){
|
||||
JobThread handlerThread = new JobThread(handler);
|
||||
handlerThread.start();
|
||||
logger.info(">>>>>>>>>>> xxl-job regist handler success, jobkey:{}, handler:{}", new Object[]{jobkey, handler});
|
||||
return HandlerRouter.JobThreadRepository.put(jobkey, handlerThread); // putIfAbsent
|
||||
JobThread jobThread = new JobThread(handler);
|
||||
jobThread.start();
|
||||
logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobkey:{}, handler:{}", new Object[]{jobkey, handler});
|
||||
return HandlerRouter.JobThreadRepository.put(jobkey, jobThread); // putIfAbsent
|
||||
}
|
||||
public static JobThread loadJobThread(String jobKey){
|
||||
return HandlerRouter.JobThreadRepository.get(jobKey);
|
||||
|
|
|
@ -27,20 +27,17 @@ public class RunAction extends IAction {
|
|||
|
||||
// handler instance
|
||||
IJobHandler jobHandler = HandlerRouter.loadJobHandler(requestModel.getExecutorHandler());
|
||||
|
||||
if (jobThread == null) {
|
||||
// jobhandler match
|
||||
if (jobHandler==null) {
|
||||
return new ResponseModel(ResponseModel.FAIL, "job handler for jobKey=[" + jobKey + "] not found.");
|
||||
}
|
||||
|
||||
if (jobThread == null) {
|
||||
jobThread = HandlerRouter.registJobThread(jobKey, jobHandler);
|
||||
} else {
|
||||
|
||||
// job handler update, kill old job thread
|
||||
if (jobThread.getHandler() != jobHandler) {
|
||||
|
||||
// kill old job thread
|
||||
jobThread.toStop("人工手动终止");
|
||||
jobThread.toStop("更换任务模式或JobHandler,终止旧任务线程");
|
||||
jobThread.interrupt();
|
||||
|
||||
// new thread, with new job handler
|
||||
|
@ -49,14 +46,25 @@ public class RunAction extends IAction {
|
|||
}
|
||||
} else {
|
||||
// glue model
|
||||
|
||||
if (jobThread == null) {
|
||||
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
|
||||
if (jobThread == null) {
|
||||
jobThread = HandlerRouter.loadJobThread(jobKey);
|
||||
}
|
||||
|
||||
// push data to queue
|
||||
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.log.XxlJobFileAppender;
|
||||
import com.xxl.job.core.router.model.RequestModel;
|
||||
import com.xxl.job.core.util.XxlJobNetCommUtil;
|
||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -88,7 +87,7 @@ public class JobThread extends Thread{
|
|||
e.printStackTrace(new PrintWriter(out));
|
||||
_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});
|
||||
|
||||
// callback handler info
|
||||
|
@ -100,7 +99,7 @@ public class JobThread extends Thread{
|
|||
} else {
|
||||
// is killed
|
||||
triggerDate.setStatus(JobHandleStatus.FAIL.name());
|
||||
triggerDate.setMsg(stopReason + "人工手动终止[业务运行中,被强制终止]");
|
||||
triggerDate.setMsg(stopReason + " [业务运行中,被强制终止]");
|
||||
TriggerCallbackThread.pushCallBack(triggerDate);
|
||||
}
|
||||
}
|
||||
|
@ -114,12 +113,9 @@ public class JobThread extends Thread{
|
|||
RequestModel triggerDate = triggerQueue.poll();
|
||||
if (triggerDate!=null) {
|
||||
// is killed
|
||||
RequestModel callback = new RequestModel();
|
||||
callback.setLogAddress(XxlJobNetCommUtil.addressToUrl(triggerDate.getLogAddress()));
|
||||
callback.setLogId(triggerDate.getLogId());
|
||||
callback.setStatus(JobHandleStatus.FAIL.name());
|
||||
callback.setMsg(stopReason + "[任务尚未执行,在调度队列中被终止]");
|
||||
TriggerCallbackThread.pushCallBack(callback);
|
||||
triggerDate.setStatus(JobHandleStatus.FAIL.name());
|
||||
triggerDate.setMsg(stopReason + " [任务尚未执行,在调度队列中被终止]");
|
||||
TriggerCallbackThread.pushCallBack(triggerDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public class TriggerCallbackThread {
|
|||
}
|
||||
public static void pushCallBack(RequestModel callback){
|
||||
callBackQueue.add(callback);
|
||||
logger.debug(">>>>>>>>>>> xxl-job, push callback request, logId:{}", callback.getLogId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue