Authored by chenchao

enhance cross time

... ... @@ -55,18 +55,21 @@ public class MailService {
}
}
public void send(String msg){
SystemConfig systemConfig = SystemConfig.getInstance();
if(!systemConfig.isSendMail()){//不发送一般发生在测试环境
logger.warn("systemConfig.sendMail is set {},u can use manage/sendMail/open to control", systemConfig.isSendMail());
return;
}
//上午10点到晚上22点发送,其他时间不发
int currentHour = DateUtil.getPart(new Date(), DateUtil.TimeUnit.hour);
if(currentHour<systemConfig.getSendMailBeginHour() || currentHour >=systemConfig.getSendMailEndHour()){
logger.warn("it's too late, don't need to send mail, thanks developer sailing");
return;
public void send(String msg, boolean forceSend){
if(!forceSend){
SystemConfig systemConfig = SystemConfig.getInstance();
if(!systemConfig.isSendMail()){//不发送一般发生在测试环境
logger.warn("systemConfig.sendMail is set {},u can use manage/sendMail/open to control", systemConfig.isSendMail());
return;
}
//上午10点到晚上22点发送,其他时间不发
int currentHour = DateUtil.getPart(new Date(), DateUtil.TimeUnit.hour);
if(currentHour<systemConfig.getSendMailBeginHour() || currentHour >=systemConfig.getSendMailEndHour()){
logger.warn("it's too late, don't need to send mail, thanks developer sailing");
return;
}
}
// 3. 创建一封邮件
RecipientAccount ra = new RecipientAccount();
ra.ccAccounts = ccAccounts;
... ... @@ -152,8 +155,4 @@ public class MailService {
private String ccAccountsStr;
}
public static void main(String[] args) {
MailService mailService = new MailService();
mailService.send("asdfasd");
}
}
... ...
... ... @@ -139,7 +139,7 @@ public class MonitorService {
}
}
if (Objects.equals(REBOOTED, req.getEventName())){
logger.info("");
logger.info("in acceptAppReport, app has reboot ,{}",req);
AppReportMap.remove(req.getIp());
}
... ... @@ -234,7 +234,7 @@ public class MonitorService {
req, currentDT, diff, timeout);
//reboot
//infoScreenService.reboot(req.getIp(), req.getScreenType());
mailService.send(buildMailContent4AppCrash(req.getIp(), req.getScreenType()).toString());
mailService.send(buildMailContent4AppCrash(req.getIp(), req.getScreenType()).toString(),false);
needRemove.add(req.getIp());
}
}
... ... @@ -289,10 +289,10 @@ public class MonitorService {
//todo 合并多个,只发送一封邮件
if(diff > timeout){
//reboot
logger.warn("HeartBeatMap find reeboot, req {},currentDT {}, diff {}, timeout {}",
logger.warn("HeartBeatMap find no heartbeat, req {},currentDT {}, diff {}, timeout {}",
packet, currentDT, diff, timeout);
//infoScreenService.reboot(req.getIp(), req.getScreenType());
mailService.send(buildMailContent(packet.getIp(), packet.getScreenType()).toString());
mailService.send(buildMailContent(packet.getIp(), packet.getScreenType()).toString(), false);
needRemove.add(packet.getIp());
}
}
... ... @@ -318,7 +318,7 @@ public class MonitorService {
if (isNotClose){
isNoticedOpenClient = true;
List<String> ips = new ArrayList<String>(HeartBeatMap.keySet());
mailService.send(buildMailContentOfExistOpenClient(ips).toString());
mailService.send(buildMailContentOfExistOpenClient(ips).toString(), true);
//移除的意义不大,心跳会不间断地上报
this.removeAll(ips);
logger.info("in sendMailIfExistOpenClient, ips {}", ips);
... ...