|
|
@ -16,8 +16,7 @@ import java.io.PrintWriter;
|
|
|
|
import java.io.StringWriter;
|
|
|
|
import java.io.StringWriter;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* handler thread
|
|
|
|
* handler thread
|
|
|
@ -106,6 +105,7 @@ public class JobThread extends Thread{
|
|
|
|
|
|
|
|
|
|
|
|
TriggerParam triggerParam = null;
|
|
|
|
TriggerParam triggerParam = null;
|
|
|
|
ReturnT<String> executeResult = null;
|
|
|
|
ReturnT<String> executeResult = null;
|
|
|
|
|
|
|
|
ExecutorService singleThread = Executors.newSingleThreadExecutor();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// to check toStop signal, we need cycle, so wo cannot use queue.take(), instand of poll(timeout)
|
|
|
|
// to check toStop signal, we need cycle, so wo cannot use queue.take(), instand of poll(timeout)
|
|
|
|
triggerParam = triggerQueue.poll(3L, TimeUnit.SECONDS);
|
|
|
|
triggerParam = triggerQueue.poll(3L, TimeUnit.SECONDS);
|
|
|
@ -121,7 +121,27 @@ public class JobThread extends Thread{
|
|
|
|
|
|
|
|
|
|
|
|
// execute
|
|
|
|
// execute
|
|
|
|
XxlJobLogger.log("<br>----------- xxl-job job execute start -----------<br>----------- Param:" + triggerParam.getExecutorParams());
|
|
|
|
XxlJobLogger.log("<br>----------- xxl-job job execute start -----------<br>----------- Param:" + triggerParam.getExecutorParams());
|
|
|
|
executeResult = handler.execute(triggerParam.getExecutorParams());
|
|
|
|
int executeTimeout = triggerParam.getExecuteTimeout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final TriggerParam finalTriggerParam = triggerParam;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<ReturnT<String>> future = singleThread.submit(new Callable<ReturnT<String>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public ReturnT<String> call() throws Exception {
|
|
|
|
|
|
|
|
return handler.execute(finalTriggerParam.getExecutorParams());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (executeTimeout > 0) {
|
|
|
|
|
|
|
|
executeResult = future.get(executeTimeout, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
executeResult = future.get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (TimeoutException timeoutException) {
|
|
|
|
|
|
|
|
executeResult = ReturnT.TIMEOUT;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (executeResult == null) {
|
|
|
|
if (executeResult == null) {
|
|
|
|
executeResult = IJobHandler.FAIL;
|
|
|
|
executeResult = IJobHandler.FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -144,6 +164,9 @@ public class JobThread extends Thread{
|
|
|
|
|
|
|
|
|
|
|
|
XxlJobLogger.log("<br>----------- JobThread Exception:" + errorMsg + "<br>----------- xxl-job job execute end(error) -----------");
|
|
|
|
XxlJobLogger.log("<br>----------- JobThread Exception:" + errorMsg + "<br>----------- xxl-job job execute end(error) -----------");
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
if (singleThread != null) {
|
|
|
|
|
|
|
|
singleThread.shutdown();
|
|
|
|
|
|
|
|
}
|
|
|
|
if(triggerParam != null) {
|
|
|
|
if(triggerParam != null) {
|
|
|
|
// callback handler info
|
|
|
|
// callback handler info
|
|
|
|
if (!toStop) {
|
|
|
|
if (!toStop) {
|
|
|
|