|
|
@ -15,7 +15,6 @@ import com.xxl.job.core.handler.HandlerRepository.HandlerParamEnum;
|
|
|
|
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.util.HttpUtil;
|
|
|
|
import com.xxl.job.core.util.HttpUtil;
|
|
|
|
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* handler thread
|
|
|
|
* handler thread
|
|
|
@ -61,10 +60,10 @@ public class HandlerThread extends Thread{
|
|
|
|
Map<String, String> handlerData = handlerDataQueue.poll();
|
|
|
|
Map<String, String> handlerData = handlerDataQueue.poll();
|
|
|
|
if (handlerData!=null) {
|
|
|
|
if (handlerData!=null) {
|
|
|
|
i= 0;
|
|
|
|
i= 0;
|
|
|
|
String trigger_log_address = handlerData.get(HandlerParamEnum.LOG_ADDRESS.name());
|
|
|
|
String log_address = handlerData.get(HandlerParamEnum.LOG_ADDRESS.name());
|
|
|
|
String trigger_log_id = handlerData.get(HandlerParamEnum.LOG_ID.name());
|
|
|
|
String log_id = handlerData.get(HandlerParamEnum.LOG_ID.name());
|
|
|
|
String handler_params = handlerData.get(HandlerParamEnum.EXECUTOR_PARAMS.name());
|
|
|
|
String handler_params = handlerData.get(HandlerParamEnum.EXECUTOR_PARAMS.name());
|
|
|
|
logIdSet.remove(trigger_log_id);
|
|
|
|
logIdSet.remove(log_id);
|
|
|
|
|
|
|
|
|
|
|
|
// parse param
|
|
|
|
// parse param
|
|
|
|
String[] handlerParams = null;
|
|
|
|
String[] handlerParams = null;
|
|
|
@ -78,7 +77,7 @@ public class HandlerThread extends Thread{
|
|
|
|
JobHandleStatus _status = JobHandleStatus.FAIL;
|
|
|
|
JobHandleStatus _status = JobHandleStatus.FAIL;
|
|
|
|
String _msg = null;
|
|
|
|
String _msg = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
XxlJobFileAppender.contextHolder.set(trigger_log_id);
|
|
|
|
XxlJobFileAppender.contextHolder.set(log_id);
|
|
|
|
logger.info(">>>>>>>>>>> xxl-job handle start.");
|
|
|
|
logger.info(">>>>>>>>>>> xxl-job handle start.");
|
|
|
|
_status = handler.execute(handlerParams);
|
|
|
|
_status = handler.execute(handlerParams);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
@ -91,19 +90,13 @@ public class HandlerThread extends Thread{
|
|
|
|
new Object[]{handlerParams, _status, _msg});
|
|
|
|
new Object[]{handlerParams, _status, _msg});
|
|
|
|
|
|
|
|
|
|
|
|
// callback handler info
|
|
|
|
// callback handler info
|
|
|
|
|
|
|
|
if (!toStop) {
|
|
|
|
HashMap<String, String> params = new HashMap<String, String>();
|
|
|
|
HashMap<String, String> params = new HashMap<String, String>();
|
|
|
|
params.put("trigger_log_id", trigger_log_id);
|
|
|
|
params.put("log_id", log_id);
|
|
|
|
params.put("status", _status.name());
|
|
|
|
params.put("status", _status.name());
|
|
|
|
params.put("msg", _msg);
|
|
|
|
params.put("msg", _msg);
|
|
|
|
RemoteCallBack callback = null;
|
|
|
|
HandlerRepository.pushCallBack(HttpUtil.addressToUrl(log_address), params);
|
|
|
|
logger.info(">>>>>>>>>>> xxl-job callback start.");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
callback = HttpUtil.post(HttpUtil.addressToUrl(trigger_log_address), params);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.info("HandlerThread Exception:", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logger.info(">>>>>>>>>>> xxl-job callback end, params:{}, result:{}", new Object[]{params, callback.toString()});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
logIdSet.clear();
|
|
|
|
logIdSet.clear();
|
|
|
|