提交 ee5b0fdc authored 作者: 高鹏's avatar 高鹏

优化下命名

上级 23c549a3
...@@ -88,12 +88,12 @@ public class XxlJobExecutor implements ApplicationContextAware { ...@@ -88,12 +88,12 @@ public class XxlJobExecutor implements ApplicationContextAware {
JobLogFileCleanThread.getInstance().start(logRetentionDays); JobLogFileCleanThread.getInstance().start(logRetentionDays);
} }
public void destroy(){ public void destroy(){
// 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."); removeJobThread(item.getKey(), "web container destroy and kill the job.");
} }
JobThreadRepository.clear(); jobThreadRepository.clear();
} }
// destory executor-server // destory executor-server
...@@ -174,13 +174,13 @@ public class XxlJobExecutor implements ApplicationContextAware { ...@@ -174,13 +174,13 @@ public class XxlJobExecutor implements ApplicationContextAware {
// ---------------------- job thread repository ---------------------- // ---------------------- job thread repository ----------------------
private static ConcurrentHashMap<Integer, JobThread> JobThreadRepository = new ConcurrentHashMap<Integer, JobThread>(); private static ConcurrentHashMap<Integer, JobThread> jobThreadRepository = new ConcurrentHashMap<Integer, JobThread>();
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){ public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){
JobThread newJobThread = new JobThread(jobId, handler); JobThread newJobThread = new JobThread(jobId, handler);
newJobThread.start(); newJobThread.start();
logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler}); logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});
JobThread oldJobThread = JobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!! JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!!
if (oldJobThread != null) { if (oldJobThread != null) {
oldJobThread.toStop(removeOldReason); oldJobThread.toStop(removeOldReason);
oldJobThread.interrupt(); oldJobThread.interrupt();
...@@ -189,14 +189,14 @@ public class XxlJobExecutor implements ApplicationContextAware { ...@@ -189,14 +189,14 @@ public class XxlJobExecutor implements ApplicationContextAware {
return newJobThread; return newJobThread;
} }
public static void removeJobThread(int jobId, String removeOldReason){ public static void 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();
} }
} }
public static JobThread loadJobThread(int jobId){ public static JobThread loadJobThread(int jobId){
JobThread jobThread = JobThreadRepository.get(jobId); JobThread jobThread = jobThreadRepository.get(jobId);
return jobThread; return jobThread;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论