【fix sonar】 JobTriggerPoolHelper.java文件
This commit is contained in:
+14
-16
@@ -30,26 +30,28 @@ public class JobTriggerPoolHelper {
|
||||
XxlJobAdminConfig.getAdminConfig().getTriggerPoolFastMax(),
|
||||
60L,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(1000),
|
||||
new ThreadFactory() {
|
||||
new LinkedBlockingQueue<>(1000),
|
||||
r-> new Thread(r, "xxl-job, admin JobTriggerPoolHelper-fastTriggerPool-" + r.hashCode()));
|
||||
/*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() {
|
||||
new LinkedBlockingQueue<>(2000),
|
||||
r-> new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode()));
|
||||
/*new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
return new Thread(r, "xxl-job, admin JobTriggerPoolHelper-slowTriggerPool-" + r.hashCode());
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
|
||||
@@ -77,16 +79,14 @@ public class JobTriggerPoolHelper {
|
||||
final String addressList) {
|
||||
|
||||
// choose thread pool
|
||||
ThreadPoolExecutor triggerPool_ = fastTriggerPool;
|
||||
ThreadPoolExecutor triggerPool = fastTriggerPool;
|
||||
AtomicInteger jobTimeoutCount = jobTimeoutCountMap.get(jobId);
|
||||
if (jobTimeoutCount!=null && jobTimeoutCount.get() > 10) { // job-timeout 10 times in 1 min
|
||||
triggerPool_ = slowTriggerPool;
|
||||
triggerPool = slowTriggerPool;
|
||||
}
|
||||
|
||||
// trigger
|
||||
triggerPool_.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
triggerPool.execute(()-> {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -98,9 +98,9 @@ public class JobTriggerPoolHelper {
|
||||
} finally {
|
||||
|
||||
// check timeout-count-map
|
||||
long minTim_now = System.currentTimeMillis()/60000;
|
||||
if (minTim != minTim_now) {
|
||||
minTim = minTim_now;
|
||||
long minTimNow = System.currentTimeMillis()/60000;
|
||||
if (minTim != minTimNow) {
|
||||
minTim = minTimNow;
|
||||
jobTimeoutCountMap.clear();
|
||||
}
|
||||
|
||||
@@ -114,8 +114,6 @@ public class JobTriggerPoolHelper {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user