|
@@ -53,13 +53,10 @@ public class FaultRefreshService implements ApplicationRunner {
|
|
|
while (true) {
|
|
|
try {
|
|
|
toRefresh();
|
|
|
+ Thread.sleep(30 * 1000);
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
- try {
|
|
|
- Thread.sleep(10 * 1000);
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -68,21 +65,9 @@ public class FaultRefreshService implements ApplicationRunner {
|
|
|
*/
|
|
|
private void toRefresh() {
|
|
|
calendar = Calendar.getInstance();
|
|
|
- calendar.add(Calendar.MINUTE, -10);
|
|
|
+ calendar.add(Calendar.MINUTE, -5);
|
|
|
String s = dateFormat.format(calendar.getTime());
|
|
|
|
|
|
- /** 每次启动先缓存一次 **/
|
|
|
- if (infoCache.faultMap.size() == 0){
|
|
|
- List<FaultInfo> faultRecent = shardingBuilder.sharding().getFaultRecent(s);
|
|
|
- List<FaultInfo> collect = faultRecent.stream().filter(f -> f.getCategory1().equals("FJ") && f.getCategory2().equals("GZ")).collect(Collectors.toList());
|
|
|
- Map<Long, FaultInfo> map = collect.stream().collect(Collectors.toMap(FaultInfo::getId, Function.identity(), (key1, key2) -> key2));
|
|
|
- for (FaultInfo fi : map.values()) {
|
|
|
- if (!infoCache.faultMap.containsKey(fi.getId()+fi.getFaultTime()+fi.getSnapID())) {
|
|
|
- infoCache.faultMap.put(fi.getId()+fi.getFaultTime()+fi.getSnapID(), fi);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
List<FaultInfo> faultRecent = shardingBuilder.sharding().getFaultRecent(s);
|
|
|
List<FaultInfo> collect = faultRecent.stream().filter(f -> f.getCategory1().equals("FJ") && f.getCategory2().equals("GZ")).collect(Collectors.toList());
|
|
|
Map<Long, FaultInfo> map = collect.stream().collect(Collectors.toMap(FaultInfo::getId, Function.identity(), (key1, key2) -> key2));
|
|
@@ -94,7 +79,7 @@ public class FaultRefreshService implements ApplicationRunner {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /** 缓存数据量太大于2000条时 清除部分缓存 **/
|
|
|
+ /** 缓存数据量太大于1000条时 清除部分缓存 **/
|
|
|
if (infoCache.faultMap.size() > 1000){
|
|
|
int count = 0;
|
|
|
for (Iterator<Map.Entry<String, FaultInfo>> it = infoCache.faultMap.entrySet().iterator(); it.hasNext();){
|