|
|
|
@ -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(); |
|
|
|
|