|
|
@ -85,8 +85,9 @@ public class MonitorServiceImpl implements MonitorService { |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 60L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); |
|
|
|
private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 2L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean isSendMail = true; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.equipment.emInfo.emInfoList}") |
|
|
|
@Value("${hzims.equipment.emInfo.emInfoList}") |
|
|
|
public String device_cache_final; |
|
|
|
public String device_cache_final; |
|
|
@ -232,18 +233,19 @@ public class MonitorServiceImpl implements MonitorService { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// 等待所有线程执行完成(至多等待三秒,超过三秒任务认为线程发生阻塞)
|
|
|
|
// 等待所有线程执行完成(至多等待三秒,超过三秒任务认为线程发生阻塞)
|
|
|
|
boolean flag = countDownLatch.await(3,TimeUnit.SECONDS); |
|
|
|
boolean flag = countDownLatch.await(3,TimeUnit.SECONDS); |
|
|
|
if(!flag){ |
|
|
|
if(!flag && isSendMail){ |
|
|
|
log.error("实时数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
log.error("实时数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
isSendMail = false; |
|
|
|
// 发生邮件
|
|
|
|
// 发生邮件
|
|
|
|
this.sendMonthReport("实时数据运行堵塞"); |
|
|
|
this.sendMonthReport("实时数据运行堵塞"); |
|
|
|
|
|
|
|
}else if(flag){ |
|
|
|
|
|
|
|
// redis 存储
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(real_cache_final,JSONObject.toJSONString(valueMap)); |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(real_gather_cache_final,JSONObject.toJSONString(keyMap)); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
} |
|
|
|
} |
|
|
|
// redis 存储
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(real_cache_final,JSONObject.toJSONString(valueMap)); |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(real_gather_cache_final,JSONObject.toJSONString(keyMap)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -310,8 +312,7 @@ public class MonitorServiceImpl implements MonitorService { |
|
|
|
// 切割数据遍历
|
|
|
|
// 切割数据遍历
|
|
|
|
for(Map<String, List<StationAttributeEntity>> item : limit){ |
|
|
|
for(Map<String, List<StationAttributeEntity>> item : limit){ |
|
|
|
// 提交线程任务
|
|
|
|
// 提交线程任务
|
|
|
|
pool.submit(()->{ |
|
|
|
pool.execute(()->{ |
|
|
|
try{ |
|
|
|
|
|
|
|
item.forEach((key,value)->{ |
|
|
|
item.forEach((key,value)->{ |
|
|
|
RealStationVo realStation = new RealStationVo(); |
|
|
|
RealStationVo realStation = new RealStationVo(); |
|
|
|
// 设备信息
|
|
|
|
// 设备信息
|
|
|
@ -328,26 +329,23 @@ public class MonitorServiceImpl implements MonitorService { |
|
|
|
realStations.add(realStation); |
|
|
|
realStations.add(realStation); |
|
|
|
}); |
|
|
|
}); |
|
|
|
countDownLatch.countDown(); |
|
|
|
countDownLatch.countDown(); |
|
|
|
}catch (Exception e){ |
|
|
|
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
// 等待所有线程执行完成
|
|
|
|
// 等待所有线程执行完成
|
|
|
|
try { |
|
|
|
try { |
|
|
|
// 等待所有线程执行完成(至多等待二秒,超过二秒任务认为线程发生阻塞)
|
|
|
|
// 等待所有线程执行完成(至多等待二秒,超过二秒任务认为线程发生阻塞)
|
|
|
|
boolean flag = countDownLatch.await(2,TimeUnit.SECONDS); |
|
|
|
boolean flag = countDownLatch.await(3,TimeUnit.SECONDS); |
|
|
|
if(!flag){ |
|
|
|
if(!flag && isSendMail){ |
|
|
|
log.error("集中监控数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
log.error("集中监控数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
isSendMail = false; |
|
|
|
// 发生邮件
|
|
|
|
// 发生邮件
|
|
|
|
this.sendMonthReport("集中监控数据运行堵塞"); |
|
|
|
this.sendMonthReport("集中监控数据运行堵塞"); |
|
|
|
|
|
|
|
}else if(flag){ |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(moniter_station_cache_final, realStations); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
} |
|
|
|
} |
|
|
|
redisTemplate.opsForValue().set(moniter_station_cache_final, realStations); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|