/** * <p>getOutageCalendarNames</p> * * @return a {@link java.util.Collection} object. * @throws java.io.IOException if any. */ public Collection<String> getOutageCalendarNames() throws IOException { return getConfiguration().getOutageCalendars(); } }
/** * This method wraps the call to the database to get a sequence notice ID * from the database. * * @return int, the sequence id from the database, 0 by default if there is * database trouble * @throws java.sql.SQLException if any. * @throws java.io.IOException if any. */ public int getNoticeId() throws SQLException, IOException { return getNxtId(m_configManager.getNextNotifIdSql()); }
/** * <p>getUserNotifId</p> * * @return a int. * @throws java.sql.SQLException if any. * @throws java.io.IOException if any. */ public int getUserNotifId() throws SQLException, IOException { return getNxtId(m_configManager.getNextUserNotifIdSql()); }
protected void onInit() { try { LOG.info("Notification status = {}", getConfigManager().getNotificationStatus()); final List<Queue> queues = getConfigManager().getConfiguration().getQueues(); for (final Queue queue : queues) { final NoticeQueue curQueue = new NoticeQueue();
private void automaticAcknowledge(Event event, boolean notifsOn) { try { Collection<AutoAcknowledge> autoAcks = getNotifdConfigManager().getAutoAcknowledges(); sendResolvedNotifications(notifIDs, event, curAck.getResolutionPrefix(), getNotifdConfigManager().getConfiguration().getNumericSkipResolutionPrefix()); return; if (!getNotifdConfigManager().getConfiguration().getAutoAcknowledgeAlarm().isPresent()) { return; final AutoAcknowledgeAlarm autoAck = getNotifdConfigManager().getConfiguration().getAutoAcknowledgeAlarm().get(); if ( !autoAck.getUeis().isEmpty() && !autoAck.getUeis().contains(event.getUei()) ) { return; sendResolvedNotifications(notifIDs, event, autoAck.getResolutionPrefix(), getNotifdConfigManager().getConfiguration().getNumericSkipResolutionPrefix());
update(); List<Notification> notifList = new ArrayList<>(); boolean matchAll = getConfigManager().getNotificationMatch(); boolean parmsmatched = getConfigManager().matchNotificationParameters(event, curNotif);
/** * Turns the notifd service off * * @throws java.io.IOException if any. */ public final void turnNotifdOff() throws IOException { configuration.setStatus("off"); saveCurrent(); }
/** * <p>computeNullSafeStatus</p> * * @return false if status is not defined in configuration as "on". */ public boolean computeNullSafeStatus() { String notificationStatus = null; try { notificationStatus = getNotifdConfigManager().getNotificationStatus(); } catch (IOException e) { LOG.error("onEvent: IO problem marshalling configuration", e); } return "on".equalsIgnoreCase(notificationStatus); }
/** * Returns true if an auto acknowledgment exists for the specificed event, * such that the arrival of some second, different event will auto * acknowledge the event passed as an argument. E.g. if there is an auto ack * set up to acknowledge a nodeDown when a nodeUp is received, passing * nodeDown to this method will return true. Should this method be in * NotifdConfigFactory? */ private boolean autoAckExistsForEvent(String eventUei) { try { Collection<AutoAcknowledge> autoAcks = getNotifdConfigManager().getAutoAcknowledges(); for (AutoAcknowledge curAck : autoAcks) { if (curAck.getAcknowledge().equals(eventUei)) { return true; } } return false; } catch (Throwable e) { LOG.error("Unable to find if an auto acknowledge exists for event {} due to exception.", eventUei, e); return false; } }
Collection<String> outageCalendarNames = getNotifdConfigManager().getOutageCalendarNames(); for (String outageName : outageCalendarNames) {
/** * Turns the notifd service on * * @throws java.io.IOException if any. */ public final void turnNotifdOn() throws IOException { configuration.setStatus("on"); saveCurrent(); }
/** * <p>getAutoAcknowledges</p> * * @return a {@link java.util.Collection} object. * @throws java.io.IOException if any. */ public Collection<AutoAcknowledge> getAutoAcknowledges() throws IOException { return getConfiguration().getAutoAcknowledges(); }
/** * <p>getNextNotifIdSql</p> * * @throws java.io.IOException if any. * @return a {@link java.lang.String} object. */ public String getNextNotifIdSql() throws IOException { return getConfiguration().getNextNotifId(); }
/** * <p>getNextUserNotifIdSql</p> * * @return a {@link java.lang.String} object. * @throws java.io.IOException if any. */ public String getNextUserNotifIdSql() throws IOException { return getConfiguration().getNextUserNotifId(); }
private void setupThreadPool() throws IOException { // determine the size of the thread pool final int maxThreads = getNotifdConfigManager().getConfiguration().getMaxThreads(); // enforce no limit when the value is <= 0 final int effectiveMaxThreads = maxThreads > 0 ? maxThreads : Integer.MAX_VALUE; // make it easier to identify the notification task threads final ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat("NotificationTask-%d") .build(); // use an unbounded queue to hold any additional tasks // this may not ideal, but it's safer than the previous approach of immediately // creating a thread for every task final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(); // create the thread pool that enforces a ceiling on the number of concurrent threads m_notificationTaskExecutor = new ThreadPoolExecutor(effectiveMaxThreads, effectiveMaxThreads, 60L, TimeUnit.SECONDS, queue, threadFactory); m_notificationTaskExecutor.allowCoreThreadTimeOut(true); }
final PreparedStatement update = connection.prepareStatement(getConfigManager().getConfiguration().getAcknowledgeUpdateSql()); dbUtils.watch(update); update.setString(1, ansBy);
connection = getConnection(); d.watch(connection); final PreparedStatement statement = connection.prepareStatement(getConfigManager().getConfiguration().getOutstandingNoticesSql()); d.watch(statement);
} else if (targetName.indexOf('@') > -1) { String[] emailCommands = { getNotifdConfigManager().getConfiguration().getEmailAddressCommand() }; NotificationTask[] emailTasks = { makeEmailTask(startTime, params, noticeId, targetName, emailCommands, targetSiblings, autoNotify) }; tasks = emailTasks;
@Test public void testRebuildParameterMap() throws Exception { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); Date downDate = new Date(); anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1", "InitialGroup", downDate, 0); //bring node down now Event event = iface.createDownEvent(downDate); m_eventMgr.sendEventToListeners(event); sleep(1000); Collection<Integer> notifIds = m_db.findNoticesForEvent(event); Notification[] notification = m_notificationManager.getNotifForEvent(event); int index = 0; for (Integer notifId : notifIds) { Map<String, String> originalMap = m_eventProcessor.buildParameterMap(notification[index], event, notifId.intValue()); Map<String, String> resolutionMap = new HashMap<String, String>(originalMap); resolutionMap.put(NotificationManager.PARAM_SUBJECT, "RESOLVED: "+resolutionMap.get(NotificationManager.PARAM_SUBJECT)); resolutionMap.put(NotificationManager.PARAM_TEXT_MSG, "RESOLVED: "+resolutionMap.get(NotificationManager.PARAM_TEXT_MSG)); resolutionMap.put(NotificationManager.PARAM_NUM_MSG, "RESOLVED: "+resolutionMap.get(NotificationManager.PARAM_NUM_MSG)); Map<String, String> rebuiltMap = m_notifd.getBroadcastEventProcessor().rebuildParameterMap(notifId.intValue(), "RESOLVED: ", m_notifd.getConfigManager().getConfiguration().getNumericSkipResolutionPrefix()); assertEquals(resolutionMap, rebuiltMap); index++; } }