@Override
 protected void doCleanup(Exception exp) {
   if (null != exp && !(exp instanceof InterruptedException)) {
     exp.printStackTrace();
   }
   alarmAgent.disconnect();
 }
  public AlarmSendingThread() {

    alarmQueue = new ArrayBlockingQueue<AlarmInfo>(100);

    submittedAlarmRegistry = new ConcurrentHashMap<String, AtomicInteger>();

    alarmAgent.init();
  }
  @Override
  protected void doRun() throws Exception {
    AlarmInfo alarm;
    alarm = alarmQueue.take();
    terminationToken.reservations.decrementAndGet();

    try {
      // 将告警信息发送至告警服务器
      alarmAgent.sendAlarm(alarm);
    } catch (Exception e) {
      e.printStackTrace();
    }

    /*
     * 处理恢复告警:将相应的故障告警从注册表中删除, 使得相应故障恢复后若再次出现相同故障,该故障信息能够上报到服务器
     */
    if (AlarmType.RESUME == alarm.type) {
      String key = AlarmType.FAULT.toString() + ':' + alarm.getId() + '@' + alarm.getExtraInfo();
      submittedAlarmRegistry.remove(key);

      key = AlarmType.RESUME.toString() + ':' + alarm.getId() + '@' + alarm.getExtraInfo();
      submittedAlarmRegistry.remove(key);
    }
  }