|
@@ -4,6 +4,7 @@ import com.xxl.job.admin.core.route.ExecutorRouter;
|
4
|
4
|
import com.xxl.job.core.biz.model.ReturnT;
|
5
|
5
|
import com.xxl.job.core.biz.model.TriggerParam;
|
6
|
6
|
|
|
7
|
+import java.util.ArrayList;
|
7
|
8
|
import java.util.LinkedHashMap;
|
8
|
9
|
import java.util.List;
|
9
|
10
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -40,12 +41,24 @@ public class ExecutorRouteLRU extends ExecutorRouter {
|
40
|
41
|
jobLRUMap.putIfAbsent(jobId, lruItem);
|
41
|
42
|
}
|
42
|
43
|
|
43
|
|
- // put
|
|
44
|
+ // put new
|
44
|
45
|
for (String address: addressList) {
|
45
|
46
|
if (!lruItem.containsKey(address)) {
|
46
|
47
|
lruItem.put(address, address);
|
47
|
48
|
}
|
48
|
49
|
}
|
|
50
|
+ // remove old
|
|
51
|
+ List<String> delKeys = new ArrayList<>();
|
|
52
|
+ for (String existKey: lruItem.keySet()) {
|
|
53
|
+ if (!addressList.contains(existKey)) {
|
|
54
|
+ delKeys.add(existKey);
|
|
55
|
+ }
|
|
56
|
+ }
|
|
57
|
+ if (delKeys.size() > 0) {
|
|
58
|
+ for (String delKey: delKeys) {
|
|
59
|
+ lruItem.remove(delKey);
|
|
60
|
+ }
|
|
61
|
+ }
|
49
|
62
|
|
50
|
63
|
// load
|
51
|
64
|
String eldestKey = lruItem.entrySet().iterator().next().getKey();
|