|
|
@ -84,33 +84,26 @@ public class XxlJobExecutor {
|
|
|
|
initRpcProvider(ip, port, appName, accessToken);
|
|
|
|
initRpcProvider(ip, port, appName, accessToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void destroy(){
|
|
|
|
public void destroy(){
|
|
|
|
|
|
|
|
|
|
|
|
List<JobThread> runningThreads = new ArrayList<>(jobThreadRepository.values());
|
|
|
|
|
|
|
|
if (logger.isInfoEnabled()) {
|
|
|
|
|
|
|
|
logger.info("running threads {}", runningThreads);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// destory executor-server
|
|
|
|
// destory executor-server
|
|
|
|
stopRpcProvider();
|
|
|
|
stopRpcProvider();
|
|
|
|
|
|
|
|
|
|
|
|
// destory jobThreadRepository
|
|
|
|
// destory jobThreadRepository
|
|
|
|
if (jobThreadRepository.size() > 0) {
|
|
|
|
if (jobThreadRepository.size() > 0) {
|
|
|
|
for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
|
|
|
|
for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
|
|
|
|
removeJobThread(item.getKey(), "web container destroy and kill the job.");
|
|
|
|
JobThread oldJobThread = removeJobThread(item.getKey(), "web container destroy and kill the job.");
|
|
|
|
|
|
|
|
// wait for job thread push result to callback queue
|
|
|
|
|
|
|
|
if (oldJobThread != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
oldJobThread.join();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
logger.error(">>>>>>>>>>> xxl-job, JobThread destroy(join) error, jobId:{}", item.getKey(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jobThreadRepository.clear();
|
|
|
|
jobThreadRepository.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jobHandlerRepository.clear();
|
|
|
|
jobHandlerRepository.clear();
|
|
|
|
|
|
|
|
|
|
|
|
for (JobThread runningThread : runningThreads) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// wait for all job thread push result to callback queue
|
|
|
|
|
|
|
|
runningThread.join();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
logger.warn("interrupted while stopping {}", runningThread);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// destory JobLogFileCleanThread
|
|
|
|
// destory JobLogFileCleanThread
|
|
|
|
JobLogFileCleanThread.getInstance().toStop();
|
|
|
|
JobLogFileCleanThread.getInstance().toStop();
|
|
|
@ -246,12 +239,15 @@ public class XxlJobExecutor {
|
|
|
|
|
|
|
|
|
|
|
|
return newJobThread;
|
|
|
|
return newJobThread;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void removeJobThread(int jobId, String removeOldReason){
|
|
|
|
public static JobThread removeJobThread(int jobId, String removeOldReason){
|
|
|
|
JobThread oldJobThread = jobThreadRepository.remove(jobId);
|
|
|
|
JobThread oldJobThread = jobThreadRepository.remove(jobId);
|
|
|
|
if (oldJobThread != null) {
|
|
|
|
if (oldJobThread != null) {
|
|
|
|
oldJobThread.toStop(removeOldReason);
|
|
|
|
oldJobThread.toStop(removeOldReason);
|
|
|
|
oldJobThread.interrupt();
|
|
|
|
oldJobThread.interrupt();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return oldJobThread;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static JobThread loadJobThread(int jobId){
|
|
|
|
public static JobThread loadJobThread(int jobId){
|
|
|
|
JobThread jobThread = jobThreadRepository.get(jobId);
|
|
|
|
JobThread jobThread = jobThreadRepository.get(jobId);
|
|
|
|