【fix sonar】ExecutorRouteRound.java文件
This commit is contained in:
+5
-5
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user