@Override public void reloadConfig() { EventBuilder ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName()); ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "DroolsCorrelationEngine-" + m_name); try { LOG.info("Reloading configuration for engine {}", m_name); EngineConfiguration cfg = JaxbUtils.unmarshal(EngineConfiguration.class, m_configPath); Optional<RuleSet> opt = cfg.getRuleSetCollection().stream().filter(rs -> rs.getName().equals(getName())).findFirst(); if (opt.isPresent()) { marshallStateToDisk(true); opt.get().updateEngine(this); initialize(); } else { ebldr.setUei(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI); ebldr.addParam(EventConstants.PARM_REASON, "RuleSet not found on " + m_configPath); } } catch (Exception e) { ebldr.setUei(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI); ebldr.addParam(EventConstants.PARM_REASON, e.getMessage()); } finally { sendEvent(ebldr.getEvent()); } }
/** * <p>Constructor for EventBuilder.</p> * * @param uei a {@link java.lang.String} object. * @param source a {@link java.lang.String} object. * @param date a {@link java.util.Date} object. */ public EventBuilder(final String uei, final String source, final Date date) { m_event = new Event(); setUei(uei); setTime(date); setSource(source); checkForIllegalUei(); }
@Override public void reloadConfig() { EventBuilder ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName()); ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "DroolsCorrelationEngine-" + m_name); try { LOG.info("Reloading configuration for engine {}", m_name); EngineConfiguration cfg = JaxbUtils.unmarshal(EngineConfiguration.class, m_configPath); Optional<RuleSet> opt = cfg.getRuleSetCollection().stream().filter(rs -> rs.getName().equals(getName())).findFirst(); if (opt.isPresent()) { marshallStateToDisk(true); opt.get().updateEngine(this); initialize(); } else { ebldr.setUei(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI); ebldr.addParam(EventConstants.PARM_REASON, "RuleSet not found on " + m_configPath); } } catch (Exception e) { ebldr.setUei(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI); ebldr.addParam(EventConstants.PARM_REASON, e.getMessage()); } finally { sendEvent(ebldr.getEvent()); } }
/** * Checks the message for substring matches to a {@link UeiMatch}. If the message * matches, then the UEI is updated (or the event is discarded if the discard * UEI is used). Parameter assignments are NOT performed for substring matches. * * @param message * @param uei * @param bldr * @param discardUei * @return * @throws MessageDiscardedException */ private static boolean matchSubstring(String message, final UeiMatch uei, final EventBuilder bldr, final String discardUei) throws MessageDiscardedException { final boolean traceEnabled = LOG.isTraceEnabled(); if (message.contains(uei.getMatch().getExpression())) { if (discardUei.equals(uei.getUei())) { if (traceEnabled) LOG.trace("Specified UEI '{}' is same as discard-uei, discarding this message.", uei.getUei()); throw new MessageDiscardedException(); } else { // Update the UEI to the new value if (traceEnabled) LOG.trace("Changed the UEI of a Syslogd event, based on substring match, to : {}", uei.getUei()); bldr.setUei(uei.getUei()); return true; } } else { if (traceEnabled) LOG.trace("No substring match for text of a Syslogd event to : {}", uei.getMatch().getExpression()); return false; } }
bldr.setUei(uei.getUei());
bldr.setUei("uei.opennms.org/syslogd/" + facilityTxt + "/" + priorityTxt); bldr.setSource("syslogd");