代码优化,ConcurrentHashMap变量类型改为ConcurrentMap,避免因不同版本实现不同导致的兼容性问题;

pull/10/head
xuxueli 6 years ago
parent 174f5cfb02
commit 40607e44ca

@ -1503,6 +1503,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 16、任务日志主键调整为long防止海量日志情况下数据溢出 - 16、任务日志主键调整为long防止海量日志情况下数据溢出
- 17、任务日志列表交互优化操作按钮合并为分割按钮 - 17、任务日志列表交互优化操作按钮合并为分割按钮
- 18、HttpJobHandler优化响应数据指定UTF-8格式避免中文乱码 - 18、HttpJobHandler优化响应数据指定UTF-8格式避免中文乱码
- 19、代码优化ConcurrentHashMap变量类型改为ConcurrentMap避免因不同版本实现不同导致的兼容性问题
### 6.26 版本 v2.1.1 Release Notes[规划中] ### 6.26 版本 v2.1.1 Release Notes[规划中]

@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/** /**
* @author xuxueli 2018-10-28 00:18:17 * @author xuxueli 2018-10-28 00:18:17
@ -112,7 +113,7 @@ public class XxlJobScheduler implements InitializingBean, DisposableBean {
// ---------------------- executor-client ---------------------- // ---------------------- executor-client ----------------------
private static ConcurrentHashMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>(); private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>();
public static ExecutorBiz getExecutorBiz(String address) throws Exception { public static ExecutorBiz getExecutorBiz(String address) throws Exception {
// valid // valid
if (address==null || address.trim().length()==0) { if (address==null || address.trim().length()==0) {

@ -6,6 +6,7 @@ import com.xxl.job.core.biz.model.TriggerParam;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/** /**
* JOB使 * JOB使
@ -16,7 +17,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class ExecutorRouteLFU extends ExecutorRouter { public class ExecutorRouteLFU extends ExecutorRouter {
private static ConcurrentHashMap<Integer, HashMap<String, Integer>> jobLfuMap = new ConcurrentHashMap<Integer, HashMap<String, Integer>>(); private static ConcurrentMap<Integer, HashMap<String, Integer>> jobLfuMap = new ConcurrentHashMap<Integer, HashMap<String, Integer>>();
private static long CACHE_VALID_TIME = 0; private static long CACHE_VALID_TIME = 0;
public String route(int jobId, List<String> addressList) { public String route(int jobId, List<String> addressList) {

@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/** /**
* JOB使 * JOB使
@ -18,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class ExecutorRouteLRU extends ExecutorRouter { public class ExecutorRouteLRU extends ExecutorRouter {
private static ConcurrentHashMap<Integer, LinkedHashMap<String, String>> jobLRUMap = new ConcurrentHashMap<Integer, LinkedHashMap<String, String>>(); private static ConcurrentMap<Integer, LinkedHashMap<String, String>> jobLRUMap = new ConcurrentHashMap<Integer, LinkedHashMap<String, String>>();
private static long CACHE_VALID_TIME = 0; private static long CACHE_VALID_TIME = 0;
public String route(int jobId, List<String> addressList) { public String route(int jobId, List<String> addressList) {

@ -7,13 +7,14 @@ import com.xxl.job.core.biz.model.TriggerParam;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/** /**
* Created by xuxueli on 17/3/10. * Created by xuxueli on 17/3/10.
*/ */
public class ExecutorRouteRound extends ExecutorRouter { public class ExecutorRouteRound extends ExecutorRouter {
private static ConcurrentHashMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<Integer, Integer>(); private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<Integer, Integer>();
private static long CACHE_VALID_TIME = 0; private static long CACHE_VALID_TIME = 0;
private static int count(int jobId) { private static int count(int jobId) {
// cache clear // cache clear

@ -49,7 +49,7 @@ public class JobTriggerPoolHelper {
// job timeout count // job timeout count
private volatile long minTim = System.currentTimeMillis()/60000; // ms > min private volatile long minTim = System.currentTimeMillis()/60000; // ms > min
private volatile ConcurrentHashMap<Integer, AtomicInteger> jobTimeoutCountMap = new ConcurrentHashMap<>(); private volatile ConcurrentMap<Integer, AtomicInteger> jobTimeoutCountMap = new ConcurrentHashMap<>();
/** /**

@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/** /**
* Created by xuxueli on 2016/3/2 21:14. * Created by xuxueli on 2016/3/2 21:14.
@ -223,7 +224,7 @@ public class XxlJobExecutor {
// ---------------------- job handler repository ---------------------- // ---------------------- job handler repository ----------------------
private static ConcurrentHashMap<String, IJobHandler> jobHandlerRepository = new ConcurrentHashMap<String, IJobHandler>(); private static ConcurrentMap<String, IJobHandler> jobHandlerRepository = new ConcurrentHashMap<String, IJobHandler>();
public static IJobHandler registJobHandler(String name, IJobHandler jobHandler){ public static IJobHandler registJobHandler(String name, IJobHandler jobHandler){
logger.info(">>>>>>>>>>> xxl-job register jobhandler success, name:{}, jobHandler:{}", name, jobHandler); logger.info(">>>>>>>>>>> xxl-job register jobhandler success, name:{}, jobHandler:{}", name, jobHandler);
return jobHandlerRepository.put(name, jobHandler); return jobHandlerRepository.put(name, jobHandler);
@ -234,7 +235,7 @@ public class XxlJobExecutor {
// ---------------------- job thread repository ---------------------- // ---------------------- job thread repository ----------------------
private static ConcurrentHashMap<Integer, JobThread> jobThreadRepository = new ConcurrentHashMap<Integer, JobThread>(); private static ConcurrentMap<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();

@ -7,6 +7,7 @@ import groovy.lang.GroovyClassLoader;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/** /**
* glue factory, product class/object by name * glue factory, product class/object by name
@ -33,7 +34,7 @@ public class GlueFactory {
* groovy class loader * groovy class loader
*/ */
private GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); private GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
private ConcurrentHashMap<String, Class<?>> CLASS_CACHE = new ConcurrentHashMap<>(); private ConcurrentMap<String, Class<?>> CLASS_CACHE = new ConcurrentHashMap<>();
/** /**
* load new instance, prototype * load new instance, prototype

Loading…
Cancel
Save