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 {
private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<Integer, Integer>();
private static long CACHE_VALID_TIME = 0;
private static ConcurrentMap<Integer, Integer> routeCountEachJob = new ConcurrentHashMap<>();
private static long cacheValidTime = 0;
private static int count(int jobId) {
// cache clear
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
if (System.currentTimeMillis() > cacheValidTime) {
routeCountEachJob.clear();
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
cacheValidTime = System.currentTimeMillis() + 1000*60*60*24;
}
// count++
@@ -33,7 +33,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
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);
public void init() throws Exception {
public void init() {
// init i18n
initI18n();
@@ -46,7 +46,7 @@ public class XxlJobScheduler {
}
public void destroy() throws Exception {
public void destroy() {
// stop-schedule
JobScheduleHelper.getInstance().toStop();
@@ -77,8 +77,8 @@ public class XxlJobScheduler {
}
// ---------------------- executor-client ----------------------
private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>();
public static ExecutorBiz getExecutorBiz(String address) throws Exception {
private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<>();
public static ExecutorBiz getExecutorBiz(String address) {
// valid
if (address==null || address.trim().length()==0) {
return null;
@@ -16,6 +16,9 @@ public class CookieUtil {
// 保存路径,根路径
private static final String COOKIE_PATH = "/";
private CookieUtil() {
}
/**
* 保存
*
@@ -70,9 +73,9 @@ public class CookieUtil {
* @param key
*/
private static Cookie get(HttpServletRequest request, String key) {
Cookie[] arr_cookie = request.getCookies();
if (arr_cookie != null && arr_cookie.length > 0) {
for (Cookie cookie : arr_cookie) {
Cookie[] arrCookie = request.getCookies();
if (arrCookie != null && arrCookie.length > 0) {
for (Cookie cookie : arrCookie) {
if (cookie.getName().equals(key)) {
return cookie;
}