/** * Each implementation of the AbstractNorthbounder has a nice queue (Nagle's algorithmic) and the worker thread that processes the queue * calls this method to send alarms to the northern NMS. * * @param alarms the alarms * @throws NorthbounderException the northbounder exception */ @Override public void forwardAlarms(List<NorthboundAlarm> alarms) throws NorthbounderException { if (alarms == null) { String errorMsg = "No alarms in alarms list for BSF forwarding."; NorthbounderException e = new NorthbounderException(errorMsg); LOG.error(errorMsg, e); throw e; } LOG.info("Forwarding {} alarms to engine {}", alarms.size(), m_engine.getName()); alarms.forEach(this::process); }
/** * Each implementation of the AbstractNorthbounder has a nice queue (Nagle's algorithmic) and the worker thread that processes the queue * calls this method to send alarms to the northern NMS. * * @param alarms the alarms * @throws NorthbounderException the northbounder exception */ @Override public void forwardAlarms(List<NorthboundAlarm> alarms) throws NorthbounderException { if (alarms == null) { String errorMsg = "No alarms in alarms list for BSF forwarding."; NorthbounderException e = new NorthbounderException(errorMsg); LOG.error(errorMsg, e); throw e; } LOG.info("Forwarding {} alarms to engine {}", alarms.size(), m_engine.getName()); alarms.forEach(this::process); }
@Override public void reloadConfig() throws NorthbounderException { LOG.info("Reloading JMS northbound configuration."); try { m_configDao.reload(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the JMS northbound configuration", e); } }
/** * Each implementation of the AbstractNorthbounder has a nice queue (Nagle's algorithmic) and the worker thread that processes the queue * calls this method to send alarms to the northern NMS. * * @param alarms the alarms * @throws NorthbounderException the northbounder exception */ @Override public void forwardAlarms(List<NorthboundAlarm> alarms) throws NorthbounderException { if (alarms == null) { String errorMsg = "No alarms in alarms list for SNMP Trap forwarding."; NorthbounderException e = new NorthbounderException(errorMsg); LOG.error(errorMsg, e); throw e; } LOG.info("Forwarding {} alarms to destination {}", alarms.size(), m_trapSink.getName()); for (NorthboundAlarm alarm : alarms) { try { SnmpTrapConfig config = m_trapSink.createTrapConfig(alarm); if (config != null) { m_trapHelper.forwardTrap(config); } } catch (SnmpTrapException e) { LOG.error("Can't send trap for {}", alarm, e); } } }
/** * Reloads the configuration. */ @Override public void reloadConfig() throws NorthbounderException { // FIXME As this can be expensive, I would say do it on a per-engine basis LOG.info("Reloading BSF northbound configuration."); try { m_configDao.reload(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the BSF trap northbound configuration", e); } }
/** * Reloads the configuration. */ @Override public void reloadConfig() throws NorthbounderException { // FIXME As this can be expensive, I would say do it on a per-engine basis LOG.info("Reloading Drools northbound configuration."); try { m_configDao.reload(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the Drools northbound configuration", e); } }
/** * Reloads the configuration. */ @Override public void reloadConfig() throws NorthbounderException { LOG.info("Reloading SNMP Traps northbound configuration."); try { m_configDao.reload(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the SNMP trap northbound configuration", e); } }
/** * Reloads the configuration. */ @Override public void reloadConfig() throws NorthbounderException { // FIXME As this can be expensive, I would say do it on a per-engine basis LOG.info("Reloading BSF northbound configuration."); try { m_configDao.reload(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the BSF trap northbound configuration", e); } }
/** * Each implementation of the AbstractNorthbounder has a nice queue (Nagle's algorithmic) and the worker thread that processes the queue * calls this method to send alarms to the northern NMS. * * @param alarms the alarms * @throws NorthbounderException the northbounder exception */ @Override public void forwardAlarms(List<NorthboundAlarm> alarms) throws NorthbounderException { if (alarms == null) { String errorMsg = "No alarms in alarms list for syslog forwarding."; NorthbounderException e = new NorthbounderException(errorMsg); LOG.error(errorMsg, e); throw e; } LOG.info("Forwarding {} alarms to destination {}", alarms.size(), m_destination.getName()); for (NorthboundAlarm alarm : alarms) { try { JavaSendMailer mailer = new JavaSendMailer(getSendmailConfig(alarm), false); mailer.send(); } catch (JavaMailerException e) { LOG.error("Can't send email for {}", alarm, e); } } }
/** * Each implementation of the AbstractNorthbounder has a nice queue (Nagle's algorithmic) and the worker thread that processes the queue * calls this method to send alarms to the northern NMS. * * @param alarms the alarms * @throws NorthbounderException the northbounder exception */ @Override public void forwardAlarms(List<NorthboundAlarm> alarms) throws NorthbounderException { if (alarms == null) { String errorMsg = "No alarms in alarms list for drools forwarding."; NorthbounderException e = new NorthbounderException(errorMsg); LOG.error(errorMsg, e); throw e; } LOG.info("Forwarding {} alarms to engine {}", alarms.size(), m_engine.getName()); alarms.forEach(a -> { LOG.debug("Begin correlation for alarm {} uei: {}", a.getId(), a.getUei()); m_kieSession.insert(a); LOG.debug("End correlation for alarm {} uei: {}", a.getId(), a.getUei()); }); }
/** * Reloads the configuration. */ @Override public void reloadConfig() { LOG.info("Reloading Email northbound configuration."); try { m_configDao.reload(); m_javaMailDao.reloadConfiguration(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the SNMP trap northbound configuration", e); } }
/** * Reloads the configuration. */ @Override public void reloadConfig() throws NorthbounderException { LOG.info("Reloading Syslog northbound configuration."); try { m_configDao.reload(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); // Unregistering Syslog destinations Syslog.shutdown(); // Shutdown all Syslog instances. registerNorthnounders(); // Re-registering all Syslog destinations. } catch (Exception e) { throw new NorthbounderException("Can't reload the Syslog northbound configuration", e); } } }
@Override protected void onStop() { if (m_engine.getOnStop() != null) { LOG.debug("running stop script for BSF engine {}", getName()); try { m_manager.exec(m_engine.getLanguage(), "", 0, 0, m_engine.getOnStop()); } catch (BSFException e) { throw new NorthbounderException("Cannot execute stop script", e); } } }
@Override protected void onStop() { if (m_engine.getOnStop() != null) { LOG.debug("running stop script for BSF engine {}", getName()); try { m_manager.exec(m_engine.getLanguage(), "", 0, 0, m_engine.getOnStop()); } catch (BSFException e) { throw new NorthbounderException("Cannot execute stop script", e); } } }
/** * Reloads the configuration. */ @Override public void reloadConfig() { LOG.info("Reloading Email northbound configuration."); try { m_configDao.reload(); m_javaMailDao.reloadConfiguration(); m_registrations.forEach((k,v) -> { if (k != getName()) v.unregister();}); registerNorthnounders(); } catch (Exception e) { throw new NorthbounderException("Can't reload the SNMP trap northbound configuration", e); } }
/** * Gets the URI. * * @return the URI */ public URI getURI() { try { return new URI(getScheme(), getUserInfo(), getHost(), getPort(), getPath(), getQuery(), getFragment()); } catch (URISyntaxException e) { throw new NorthbounderException(e); } }
/** * Process. * * @param alarm the alarm * @throws NorthbounderException the northbounder exception */ private void process(NorthboundAlarm alarm) throws NorthbounderException { m_manager.registerBean("alarm", alarm); try { LOG.debug("processing alarm {} with engine {}", alarm, getName()); m_manager.exec(m_engine.getLanguage(), "", 0, 0, m_engine.getOnAlarm()); } catch (BSFException e) { throw new NorthbounderException("Cannot execute script", e); } finally { m_manager.unregisterBean("alarm"); } }
/** * Process. * * @param alarm the alarm * @throws NorthbounderException the northbounder exception */ private void process(NorthboundAlarm alarm) throws NorthbounderException { m_manager.registerBean("alarm", alarm); try { LOG.debug("processing alarm {} with engine {}", alarm, getName()); m_manager.exec(m_engine.getLanguage(), "", 0, 0, m_engine.getOnAlarm()); } catch (BSFException e) { throw new NorthbounderException("Cannot execute script", e); } finally { m_manager.unregisterBean("alarm"); } }
/** * Initialize BSF engine. * * @throws Exception the exception */ private void initializeBSFEngine() throws Exception { if (!BSFManager.isLanguageRegistered(m_engine.getLanguage())) { LOG.debug("registering BSF language {} using {}", m_engine.getLanguage(), m_engine.getClassName()); BSFManager.registerScriptingEngine(m_engine.getLanguage(), m_engine.getClassName(), m_engine.getExtensions().split(",")); } m_manager.registerBean("log", LOG); if (m_engine.getOnStart() != null) { LOG.debug("running start script for BSF engine {}", getName()); try { m_manager.exec(m_engine.getLanguage(), "", 0, 0, m_engine.getOnStart()); } catch (BSFException e) { throw new NorthbounderException("Cannot execute start script", e); } } }
/** * Initialize BSF engine. * * @throws Exception the exception */ private void initializeBSFEngine() throws Exception { if (!BSFManager.isLanguageRegistered(m_engine.getLanguage())) { LOG.debug("registering BSF language {} using {}", m_engine.getLanguage(), m_engine.getClassName()); BSFManager.registerScriptingEngine(m_engine.getLanguage(), m_engine.getClassName(), m_engine.getExtensions().split(",")); } m_manager.registerBean("log", LOG); if (m_engine.getOnStart() != null) { LOG.debug("running start script for BSF engine {}", getName()); try { m_manager.exec(m_engine.getLanguage(), "", 0, 0, m_engine.getOnStart()); } catch (BSFException e) { throw new NorthbounderException("Cannot execute start script", e); } } }