@Test public void testAddAlarmChanges() { List<AlarmChange> changes = new ArrayList<>(); changes.add(createAlarmChange(AlarmChangeType.RAISE_OR_UPDATE, ALARMTYPE1, NODEID11)); changes.add(createAlarmChange(AlarmChangeType.RAISE, ALARMTYPE2, NODEID12)); changes.add(createAlarmChange(AlarmChangeType.UPDATE, ALARMTYPE1, NODEID21)); changes.add(createAlarmChange(AlarmChangeType.CLEAR, ALARMTYPE2, NODEID21)); m_alarmQueue.addAlarmChanges(changes); m_alarmQueue.clearQueue(); verify(m_alarmService).processChanges(changes); }
public synchronized void addAlarmChanges(List<AlarmChange> changes) { if (!changes.isEmpty()) { int currentQueueSize = m_queue.size(); if (currentQueueSize + changes.size() > m_maxQueueSize) { int maxNumberToBeAdded = m_maxQueueSize - currentQueueSize; int dropped = changes.size() - maxNumberToBeAdded; LOGGER.error(null, "addAlarmChanges() queue overflow: dropping {} events", dropped); changes = changes.subList(0, maxNumberToBeAdded); m_droppedAlarms.addAndGet(dropped); } if (!changes.isEmpty()) { LOGGER.trace(null, "addAlarmChanges(): adding {} events", changes.size()); m_queue.addAll(changes); m_queueSize = m_queue.size(); } } }
AlarmQueue { public synchronized void addAlarmChanges(List<AlarmChange> changes) { if (!changes.isEmpty()) { int currentQueueSize = m_queue.size(); if (currentQueueSize + changes.size() > m_maxQueueSize) { int maxNumberToBeAdded = m_maxQueueSize - currentQueueSize; int dropped = changes.size() - maxNumberToBeAdded; LOGGER.error(null, "addAlarmChanges() queue overflow: dropping {} events", dropped); changes = changes.subList(0, maxNumberToBeAdded); m_droppedAlarms.addAndGet(dropped); } if (!changes.isEmpty()) { LOGGER.trace(null, "addAlarmChanges(): adding {} events", changes.size()); m_queue.addAll(changes); m_queueSize = m_queue.size(); } } } }
AlarmQueue { public synchronized void addAlarmChanges(List<AlarmChange> changes) { if (!changes.isEmpty()) { int currentQueueSize = m_queue.size(); if (currentQueueSize + changes.size() > m_maxQueueSize) { int maxNumberToBeAdded = m_maxQueueSize - currentQueueSize; int dropped = changes.size() - maxNumberToBeAdded; LOGGER.error(null, "addAlarmChanges() queue overflow: dropping {} events", dropped); changes = changes.subList(0, maxNumberToBeAdded); m_droppedAlarms.addAndGet(dropped); } if (!changes.isEmpty()) { LOGGER.trace(null, "addAlarmChanges(): adding {} events", changes.size()); m_queue.addAll(changes); m_queueSize = m_queue.size(); } } } AlarmQueue(InternalAlarmService service); }
AlarmQueue { public synchronized void addAlarmChanges(List<AlarmChange> changes) { if (!changes.isEmpty()) { int currentQueueSize = m_queue.size(); if (currentQueueSize + changes.size() > m_maxQueueSize) { int maxNumberToBeAdded = m_maxQueueSize - currentQueueSize; int dropped = changes.size() - maxNumberToBeAdded; LOGGER.error(null, "addAlarmChanges() queue overflow: dropping {} events", dropped); changes = changes.subList(0, maxNumberToBeAdded); m_droppedAlarms.addAndGet(dropped); } if (!changes.isEmpty()) { LOGGER.trace(null, "addAlarmChanges(): adding {} events", changes.size()); m_queue.addAll(changes); m_queueSize = m_queue.size(); } } } AlarmQueue(InternalAlarmService service); synchronized void addAlarmChanges(List<AlarmChange> changes); void clearQueue(); long getDroppedAlarms(); long getAlarmQueueSize(); }
AlarmQueue { public synchronized void addAlarmChanges(List<AlarmChange> changes) { if (!changes.isEmpty()) { int currentQueueSize = m_queue.size(); if (currentQueueSize + changes.size() > m_maxQueueSize) { int maxNumberToBeAdded = m_maxQueueSize - currentQueueSize; int dropped = changes.size() - maxNumberToBeAdded; LOGGER.error(null, "addAlarmChanges() queue overflow: dropping {} events", dropped); changes = changes.subList(0, maxNumberToBeAdded); m_droppedAlarms.addAndGet(dropped); } if (!changes.isEmpty()) { LOGGER.trace(null, "addAlarmChanges(): adding {} events", changes.size()); m_queue.addAll(changes); m_queueSize = m_queue.size(); } } } AlarmQueue(InternalAlarmService service); synchronized void addAlarmChanges(List<AlarmChange> changes); void clearQueue(); long getDroppedAlarms(); long getAlarmQueueSize();  }