private void saveAlertToMemory(AlertInfoBO alert) {
   AlertPair value = alerts.getLast();
   if (value == null) {
     AlertPair pair = new AlertPair(alert, 0L);
     try {
       alerts.add(pair);
     } catch (FifoQueueException e) {
       e.printStackTrace();
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   } else {
     long maxId = value.getMaxId();
     long newMaxId = 0;
     if (maxId + 1 < Long.MAX_VALUE) newMaxId = maxId + 1;
     AlertPair pair = new AlertPair(alert, newMaxId);
     try {
       alerts.add(pair);
     } catch (FifoQueueException e) {
       e.printStackTrace();
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
 }
 public Map<String, List<AlertInfoBO>> getNewAlert(Long maxId) {
   Map<String, List<AlertInfoBO>> value = new HashMap<String, List<AlertInfoBO>>();
   int size = alerts.size();
   long newId = maxId;
   if (size > 0) {
     List<AlertInfoBO> rtvl = new ArrayList<AlertInfoBO>();
     for (int i = 0; i < size; i++) {
       AlertPair pair = alerts.getElement(i);
       long id = pair.getMaxId();
       if (id > maxId) {
         rtvl.add(pair.getAlert());
         if (id > newId) {
           newId = id;
         }
       }
     }
     if (newId > maxId) value.put(Long.toString(newId), rtvl);
   }
   return value;
 }