LRU路由更新不及时问题修复

pull/8/MERGE
xuxueli 6 years ago
parent 0c97707087
commit 878df30bbc

@ -1427,7 +1427,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 13、执行器热部署时JobHandler重新初始化修复由此导致的 "jobhandler naming conflicts." 问题;
- 14、新增Class的加载缓存解决频繁加载Class会使jvm的方法区空间不足导致OOM的问题
- 15、调整首页报表默认区间为本周避免日志量太大查询缓慢
- 16、[迭代中]任务线程隔离:
- 16、LRU路由更新不及时问题修复
- 17、[迭代中]任务线程隔离:
- 执行器测异步响应,不存在阻塞不需要隔离;
- 调度中心共用单一调度线程池可能导致调度阻塞需要线程隔离调度线程池拆分为Fast/Slow两个针对调度较慢的执行器地址请求降级使用Slow线程池考虑是否可以任务级隔离线程池

@ -33,11 +33,25 @@ public class ExecutorRouteLFU extends ExecutorRouter {
lfuItemMap = new HashMap<String, Integer>();
jobLfuMap.putIfAbsent(jobId, lfuItemMap); // 避免重复覆盖
}
// put new
for (String address: addressList) {
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) >1000000 ) {
lfuItemMap.put(address, new Random().nextInt(addressList.size())); // 初始化时主动Random一次缓解首次压力
}
}
// remove old
List<String> delKeys = new ArrayList<>();
for (String existKey: lfuItemMap.keySet()) {
if (!addressList.contains(existKey)) {
delKeys.add(existKey);
}
}
if (delKeys.size() > 0) {
for (String delKey: delKeys) {
lfuItemMap.remove(delKey);
}
}
// load least userd count address
List<Map.Entry<String, Integer>> lfuItemList = new ArrayList<Map.Entry<String, Integer>>(lfuItemMap.entrySet());

@ -4,6 +4,7 @@ import com.xxl.job.admin.core.route.ExecutorRouter;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@ -40,12 +41,24 @@ public class ExecutorRouteLRU extends ExecutorRouter {
jobLRUMap.putIfAbsent(jobId, lruItem);
}
// put
// put new
for (String address: addressList) {
if (!lruItem.containsKey(address)) {
lruItem.put(address, address);
}
}
// remove old
List<String> delKeys = new ArrayList<>();
for (String existKey: lruItem.keySet()) {
if (!addressList.contains(existKey)) {
delKeys.add(existKey);
}
}
if (delKeys.size() > 0) {
for (String delKey: delKeys) {
lruItem.remove(delKey);
}
}
// load
String eldestKey = lruItem.entrySet().iterator().next().getKey();

Loading…
Cancel
Save