Merge remote-tracking branch 'origin/fix-bug-202303' into fix-bug-202303

This commit is contained in:
梁琦涛
2023-03-10 16:11:49 +08:00
3 changed files with 21 additions and 18 deletions
@@ -14,13 +14,13 @@ import java.util.concurrent.ConcurrentMap;
*/ */
public class ExecutorRouteRound extends ExecutorRouter { public class ExecutorRouteRound extends ExecutorRouter {
private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<Integer, Integer>(); private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<>();
private static long CACHE_VALID_TIME = 0; private static long cacheValidTime = 0;
private static int count(int jobId) { private static int count(int jobId) {
// cache clear // cache clear
if (System.currentTimeMillis() > CACHE_VALID_TIME) { if (System.currentTimeMillis() > cacheValidTime) {
routeCountEachJob.clear(); routeCountEachJob.clear();
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24; cacheValidTime = System.currentTimeMillis() + 1000*60*60*24;
} }
// count++ // count++
@@ -33,7 +33,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
@Override @Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) { public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
String address = addressList.get(count(triggerParam.getJobId())%addressList.size()); String address = addressList.get(count(triggerParam.getJobId())%addressList.size());
return new ReturnT<String>(address); return new ReturnT<>(address);
} }
} }
@@ -20,7 +20,7 @@ public class XxlJobScheduler {
private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class); private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class);
public void init() throws Exception { public void init() {
// init i18n // init i18n
initI18n(); initI18n();
@@ -46,7 +46,7 @@ public class XxlJobScheduler {
} }
public void destroy() throws Exception { public void destroy() {
// stop-schedule // stop-schedule
JobScheduleHelper.getInstance().toStop(); JobScheduleHelper.getInstance().toStop();
@@ -77,8 +77,8 @@ public class XxlJobScheduler {
} }
// ---------------------- executor-client ---------------------- // ---------------------- executor-client ----------------------
private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>(); private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<>();
public static ExecutorBiz getExecutorBiz(String address) throws Exception { public static ExecutorBiz getExecutorBiz(String address) {
// valid // valid
if (address==null || address.trim().length()==0) { if (address==null || address.trim().length()==0) {
return null; return null;
@@ -16,6 +16,9 @@ public class CookieUtil {
// 保存路径,根路径 // 保存路径,根路径
private static final String COOKIE_PATH = "/"; private static final String COOKIE_PATH = "/";
private CookieUtil() {
}
/** /**
* 保存 * 保存
* *
@@ -70,9 +73,9 @@ public class CookieUtil {
* @param key * @param key
*/ */
private static Cookie get(HttpServletRequest request, String key) { private static Cookie get(HttpServletRequest request, String key) {
Cookie[] arr_cookie = request.getCookies(); Cookie[] arrCookie = request.getCookies();
if (arr_cookie != null && arr_cookie.length > 0) { if (arrCookie != null && arrCookie.length > 0) {
for (Cookie cookie : arr_cookie) { for (Cookie cookie : arrCookie) {
if (cookie.getName().equals(key)) { if (cookie.getName().equals(key)) {
return cookie; return cookie;
} }