Package com.taobao.zeus.broadcast.alarm

Examples of com.taobao.zeus.broadcast.alarm.SMSAlarm


  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);
            }
          }
        }.start();
        if (type == 0) {
          Calendar now = Calendar.getInstance();
          int hour = now.get(Calendar.HOUR_OF_DAY);
          int day = now.get(Calendar.DAY_OF_WEEK);
          if (day == Calendar.SATURDAY || day == Calendar.SUNDAY
              || hour < 9 || hour > 18) {
            smsAlarm.alarm(his.getId(), title.toString(),
                content.toString(), null);
          }
        }
      }
      return true;
View Full Code Here

TOP

Related Classes of com.taobao.zeus.broadcast.alarm.SMSAlarm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.