}
}
private boolean timeOverAlarm(final JobHistory his, FileDescriptor fd,
long runTime, long maxTime, int type) {
final MailAlarm mailAlarm = (MailAlarm) context.getApplicationContext()
.getBean("mailAlarm");
SMSAlarm smsAlarm = (SMSAlarm) context.getApplicationContext().getBean(
"smsAlarm");
final StringBuffer title = new StringBuffer("宙斯任务超时[");
switch (type) {
case 0:
title.append("自动调度").append("] jobID=").append(his.getJobId());
break;
case 1:
title.append("手动调度").append("] jobID=").append(his.getJobId());
break;
case 2:
title.append("调试任务").append("] 脚本名称:").append(fd.getName());
}
final StringBuffer content = new StringBuffer(title);
content.append("\n已经运行时间:").append(runTime).append("分钟")
.append("\n设置最大运行时间:").append(maxTime).append("分钟")
.append("\n详情请登录zeus系统查看:http://zeus.taobao.com:9999");
try {
if (type == 2) {
//此处可以发送IM消息
} else {
//此处可以发送IM消息
new Thread() {
@Override
public void run() {
try {
Thread.sleep(6000);
mailAlarm.alarm(his.getId(), title.toString(),
content.toString().replace("\n","<br/>").replace("http://zeus.taobao.com:9999", "<a href='http://zeus.taobao.com:9999'>http://zeus.taobao.com:9999</a>"));
} catch (Exception e) {
log.error("send run timeover mail alarm failed", e);
}
}