|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.xxl.job.admin.core.thread; |
|
|
|
|
|
|
|
|
|
import com.xxl.job.admin.core.conf.XxlJobAdminConfig; |
|
|
|
|
import com.xxl.job.admin.core.trigger.TriggerTypeEnum; |
|
|
|
|
import com.xxl.job.admin.core.trigger.XxlJobTrigger; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
@ -20,31 +21,44 @@ public class JobTriggerPoolHelper { |
|
|
|
|
// ---------------------- trigger pool ----------------------
|
|
|
|
|
|
|
|
|
|
// fast/slow thread pool
|
|
|
|
|
private ThreadPoolExecutor fastTriggerPool = new ThreadPoolExecutor( |
|
|
|
|
50, |
|
|
|
|
200, |
|
|
|
|
60L, |
|
|
|
|
TimeUnit.SECONDS, |
|
|
|
|
new LinkedBlockingQueue<Runnable>(1000), |
|
|
|
|
new ThreadFactory() { |
|
|
|
|
@Override |
|
|
|
|
public Thread newThread(Runnable r) { |
|
|
|
|
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
private ThreadPoolExecutor slowTriggerPool = new ThreadPoolExecutor( |
|
|
|
|
10, |
|
|
|
|
100, |
|
|
|
|
60L, |
|
|
|
|
TimeUnit.SECONDS, |
|
|
|
|
new LinkedBlockingQueue<Runnable>(2000), |
|
|
|
|
new ThreadFactory() { |
|
|
|
|
@Override |
|
|
|
|
public Thread newThread(Runnable r) { |
|
|
|
|
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
private ThreadPoolExecutor fastTriggerPool = null; |
|
|
|
|
private ThreadPoolExecutor slowTriggerPool = null; |
|
|
|
|
|
|
|
|
|
public void start(){ |
|
|
|
|
fastTriggerPool = new ThreadPoolExecutor( |
|
|
|
|
10, |
|
|
|
|
XxlJobAdminConfig.getAdminConfig().getTriggerPoolFastMax(), |
|
|
|
|
60L, |
|
|
|
|
TimeUnit.SECONDS, |
|
|
|
|
new LinkedBlockingQueue<Runnable>(1000), |
|
|
|
|
new ThreadFactory() { |
|
|
|
|
@Override |
|
|
|
|
public Thread newThread(Runnable r) { |
|
|
|
|
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
slowTriggerPool = new ThreadPoolExecutor( |
|
|
|
|
10, |
|
|
|
|
XxlJobAdminConfig.getAdminConfig().getTriggerPoolSlowMax(), |
|
|
|
|
60L, |
|
|
|
|
TimeUnit.SECONDS, |
|
|
|
|
new LinkedBlockingQueue<Runnable>(2000), |
|
|
|
|
new ThreadFactory() { |
|
|
|
|
@Override |
|
|
|
|
public Thread newThread(Runnable r) { |
|
|
|
|
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void stop() { |
|
|
|
|
//triggerPool.shutdown();
|
|
|
|
|
fastTriggerPool.shutdownNow(); |
|
|
|
|
slowTriggerPool.shutdownNow(); |
|
|
|
|
logger.info(">>>>>>>>> xxl-job trigger thread pool shutdown success."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// job timeout count
|
|
|
|
@ -100,17 +114,19 @@ public class JobTriggerPoolHelper { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void stop() { |
|
|
|
|
//triggerPool.shutdown();
|
|
|
|
|
fastTriggerPool.shutdownNow(); |
|
|
|
|
slowTriggerPool.shutdownNow(); |
|
|
|
|
logger.info(">>>>>>>>> xxl-job trigger thread pool shutdown success."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------- helper ----------------------
|
|
|
|
|
|
|
|
|
|
private static JobTriggerPoolHelper helper = new JobTriggerPoolHelper(); |
|
|
|
|
|
|
|
|
|
public static void toStart() { |
|
|
|
|
helper.start(); |
|
|
|
|
} |
|
|
|
|
public static void toStop() { |
|
|
|
|
helper.stop(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param jobId |
|
|
|
|
* @param triggerType |
|
|
|
@ -126,8 +142,4 @@ public class JobTriggerPoolHelper { |
|
|
|
|
helper.addTrigger(jobId, triggerType, failRetryCount, executorShardingParam, executorParam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void toStop() { |
|
|
|
|
helper.stop(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|