1、"/beat",用途:用于检查心跳;直接返回成功
2、"/idleBeat",用途:用于检查忙碌状态;忙碌中(执行任务中,或者队列中有数据)
3、"/run",用途:用于执行任务;
4、"/kill",用途:用于中断线程;
5、"/log",用途:用于读取日志;
.
// com.xxl.job.core.server.EmbedServer.EmbedHttpServerHandler#process
private Object process(HttpMethod httpMethod, String uri, String requestData, String accessTokenReq) {
// valid
if (HttpMethod.POST != httpMethod) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support.");
}
if (uri==null || uri.trim().length()==0) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty.");
}
if (accessToken!=null
&& accessToken.trim().length()>0
&& !accessToken.equals(accessTokenReq)) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "The access token is wrong.");
}
// services mapping
try {
if ("/beat".equals(uri)) {
/**
* 直接返回成功
* @see com.xxl.job.core.biz.impl.ExecutorBizImpl#beat
*/
return executorBiz.beat();
} else if ("/idleBeat".equals(uri)) {
/**
* 忙碌中(执行任务中,或者队列中有数据)
* @see com.xxl.job.core.biz.impl.ExecutorBizImpl#idleBeat
*/
IdleBeatParam idleBeatParam = GsonTool.fromJson(requestData, IdleBeatParam.class);
return executorBiz.idleBeat(idleBeatParam);
} else if ("/run".equals(uri)) {
/**
* 执行任务
* @see com.xxl.job.core.biz.impl.ExecutorBizImpl#run(com.xxl.job.core.biz.model.TriggerParam)
*/
TriggerParam triggerParam = GsonTool.fromJson(requestData, TriggerParam.class);
return executorBiz.run(triggerParam);
} else if ("/kill".equals(uri)) {
KillParam killParam = GsonTool.fromJson(requestData, KillParam.class);
/**
* 中断线程
* @see com.xxl.job.core.biz.impl.ExecutorBizImpl#kill
*/
return executorBiz.kill(killParam);
} else if ("/log".equals(uri)) {
LogParam logParam = GsonTool.fromJson(requestData, LogParam.class);
/**
* 读取日志
* @see com.xxl.job.core.biz.impl.ExecutorBizImpl#log
*/
return executorBiz.log(logParam);
} else {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found.");
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ReturnT<String>(ReturnT.FAIL_CODE, "request error:" + ThrowableUtil.toString(e));
}
}
.