perf: 增加运维检测开关

dev
huangfeng 1 year ago
parent ec9ba6a373
commit f349bbbd78

@ -94,6 +94,7 @@ maintain:
termlog: /home/xymp/termLogs/ termlog: /home/xymp/termLogs/
apk: /home/xymp/apk/ apk: /home/xymp/apk/
uri: http://61.169.135.146:40085/ uri: http://61.169.135.146:40085/
check: false
cma: cma:
server: 127.0.0.1 server: 127.0.0.1

@ -8,6 +8,7 @@ import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.NewCacheService; import com.shxy.xymanager_service.service.NewCacheService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -23,6 +24,9 @@ public class MntnCheckTask {
private int max = 20; private int max = 20;
private HashMap<Integer, Long> alertMap = new HashMap<>(); private HashMap<Integer, Long> alertMap = new HashMap<>();
@Value("${maintain.check}")
private boolean needCheck;
@Resource @Resource
MntnRawReportsMapper rawReportsMapper; MntnRawReportsMapper rawReportsMapper;
@Resource @Resource
@ -54,17 +58,19 @@ public class MntnCheckTask {
@Scheduled(initialDelay = 60000, fixedDelay = 60000) @Scheduled(initialDelay = 60000, fixedDelay = 60000)
private void checkAll() { private void checkAll() {
try { if (needCheck) {
log.info("MntnCheckTask.checkAll 开始."); try {
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap(); log.info("MntnCheckTask.checkAll 开始.");
Iterator<Integer> it = terminalMap.keySet().iterator(); Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
while (shutdown == 0 && it.hasNext()) { Iterator<Integer> it = terminalMap.keySet().iterator();
Integer termId = it.next(); while (shutdown == 0 && it.hasNext()) {
this.checkOne(termId); Integer termId = it.next();
this.checkOne(termId);
}
log.info("MntnCheckTask.checkAll 结束.");
} catch (Exception e) {
log.error("MntnCheckTask.checkAll error.", e);
} }
log.info("MntnCheckTask.checkAll 结束.");
} catch (Exception e) {
log.error("MntnCheckTask.checkAll error.", e);
} }
} }

Loading…
Cancel
Save