优化下命名

pull/8/MERGE
高鹏 6 years ago
parent 23c549a3b6
commit ee5b0fdc76

@ -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 {
// ---------------------- 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 {
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;
} }

Loading…
Cancel
Save