@Override public boolean accepts(NorthboundAlarm alarm) { if (!m_config.isEnabled()) { LOG.warn("JMS Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); return true; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
@Override public boolean accepts(NorthboundAlarm alarm) { if (m_config.getAcceptableUeis() == null || m_config.getAcceptableUeis().contains(alarm.getUei())) { return true; } return false; }
/** * The abstraction makes a call here to determine if the alarm should be placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("BSF Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("BSF Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); boolean passed = m_engine.accepts(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * The abstraction makes a call here to determine if the alarm should be placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("Email Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("Email Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); boolean passed = m_destination.accepts(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * The abstraction makes a call here to determine if the alarm should be placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("BSF Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("BSF Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); boolean passed = m_engine.accepts(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * The abstraction makes a call here to determine if the alarm should be placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("SNMP Trap Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("SNMP Trap Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); boolean passed = m_trapSink.accepts(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * The abstraction makes a call here to determine if the alarm should be placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("Drools Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("Drools Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); boolean passed = m_engine.accepts(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * The abstraction makes a call here to determine if the alarm should be placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("Email Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("Email Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); boolean passed = m_destination.accepts(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * 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()); }); }
/** * The abstraction makes a call here to determine if the alarm should be * placed on the queue of alarms to be sent northerly. * * @param alarm the alarm * @return true, if successful */ @Override public boolean accepts(NorthboundAlarm alarm) { if (!initialized) { LOG.warn("Syslog Northbounder {} has not been properly initialized, rejecting alarm {}.", getName(), alarm.getUei()); return false; } if (!getConfig().isEnabled()) { LOG.warn("Syslog Northbounder {} is currently disabled, rejecting alarm {}.", getName(), alarm.getUei()); return false; } LOG.debug("Validating UEI of alarm: {}", alarm.getUei()); if (getConfig().getUeis() == null || getConfig().getUeis().contains(alarm.getUei())) { LOG.debug("UEI: {}, accepted.", alarm.getUei()); if (m_destination.getFilters() == null) { return true; } boolean passed = m_destination.passFilter(alarm); LOG.debug("Filters: {}, passed ? {}.", alarm.getUei(), passed); return passed; } LOG.debug("UEI: {}, rejected.", alarm.getUei()); return false; }
/** * Evaluates a SPEL expression based on a given northbound alarm * * @param expression the expression * @param alarm the northbound alarm * @return the string */ private String evaluate(String expression, NorthboundAlarm alarm) { if (expression == null) { return null; } try { StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(expression); return (String) exp.getValue(context, String.class); } catch (Exception e) { LOG.warn("Can't evaluate expression {} for alarm {} because: {}", getValue(), alarm.getUei(), e.getMessage()); } return null; } }
/** * Accepts. * <p>If the engine doesn't have filter, the method will return true.</p> * <p>If the method has a filter, it will be evaluated.</p> * * @param alarm the alarm * @return true, if successful */ public boolean accepts(NorthboundAlarm alarm) { if (getFilter() != null) { StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(m_filter); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("accepts: can't evaluate expression {} for alarm {} because: {}", getFilter(), alarm.getUei(), e.getMessage()); } LOG.debug("accepts: checking {} ? {}", m_filter, passed); return passed; } return true; }
/** * Accepts. * <p>If the engine doesn't have filter, the method will return true.</p> * <p>If the method has a filter, it will be evaluated.</p> * * @param alarm the alarm * @return true, if successful */ public boolean accepts(NorthboundAlarm alarm) { if (getFilter() != null) { StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(m_filter); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("accepts: can't evaluate expression {} for alarm {} because: {}", getFilter(), alarm.getUei(), e.getMessage()); } LOG.debug("accepts: checking {} ? {}", m_filter, passed); return passed; } return true; }
/** * Verifies if the mapping object accepts a given northbound alarm. * * @param alarm the northbound alarm * @return true, if the alarm is accepted */ public boolean accepts(NorthboundAlarm alarm) { StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(getRule()); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("mapping accepts: can't evaluate expression {} for alarm {} because: {}", getRule(), alarm.getUei(), e.getMessage()); } LOG.debug("mapping accepts: checking {} ? {}", getRule(), passed); return passed; }
/** * Accepts. * <p>If the engine doesn't have filter, the method will return true.</p> * <p>If the method has a filter, it will be evaluated.</p> * * @param alarm the alarm * @return true, if successful */ public boolean accepts(NorthboundAlarm alarm) { if (getFilter() != null) { StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(m_filter); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("accepts: can't evaluate expression {} for alarm {} because: {}", getFilter(), alarm.getUei(), e.getMessage()); } LOG.debug("accepts: checking {} ? {}", m_filter, passed); return passed; } return true; }
/** * Checks if the alarm is accepted by the filter. * * @param alarm the northbound alarm * @return true, if successful */ public boolean accepts(NorthboundAlarm alarm) { if (!isEnabled()) { return false; } StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(getRule()); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("accepts: can't evaluate expression {} for alarm {} because: {}", getRule(), alarm.getUei(), e.getMessage()); } LOG.debug("accepts: checking {} ? {}", getRule(), passed); return passed; }
/** * Checks if the alarm is accepted by the filter. * * @param alarm the northbound alarm * @return true, if successful */ public boolean accepts(NorthboundAlarm alarm) { if (!isEnabled()) { return false; } StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(getRule()); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("accepts: can't evaluate expression {} for alarm {} because: {}", getRule(), alarm.getUei(), e.getMessage()); } LOG.debug("accepts: checking {} ? {}", getRule(), passed); return passed; }
/** * Pass filter. * * @param alarm the alarm * @return true, if successful */ public boolean passFilter(NorthboundAlarm alarm) { if (!isEnabled()) { return false; } StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(getRule()); boolean passed = false; try { passed = (Boolean)exp.getValue(context, Boolean.class); } catch (Exception e) { LOG.warn("passFilter: can't evaluate expression {} for alarm {} because: {}", getRule(), alarm.getUei(), e.getMessage()); } LOG.debug("passFilter: checking {} ? {}", getRule(), passed); return passed; } }
/** * Verifies if the mapping group object accepts a given northbound alarm. * * @param alarm the northbound alarm * @return true, if the alarm is accepted. */ public boolean accepts(NorthboundAlarm alarm) { StandardEvaluationContext context = new StandardEvaluationContext(alarm); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(getRule()); boolean passed = false; try { passed = (Boolean) exp.getValue(context, Boolean.class); if (passed) { boolean mappingAccepted = false; for (SnmpTrapMapping mapping : getMappings()) { if (mapping.accepts(alarm)) { mappingAccepted = true; break; } } passed = mappingAccepted; } } catch (Exception e) { LOG.warn("mapping group accepts: can't evaluate expression {} for alarm {} because: {}", getRule(), alarm.getUei(), e.getMessage()); } LOG.debug("mapping group accepts: {} ? {}", getRule(), passed); return passed; }
mapping.put("ticketId", nullSafeToString(alarm.getTicketId(), defaultMapping)); mapping.put("ticketState", nullSafeToString(alarm.getTicketState(), defaultMapping)); mapping.put("alarmUei", nullSafeToString(alarm.getUei(), defaultMapping)); mapping.put("alarmKey", nullSafeToString(alarm.getAlarmKey(), defaultMapping)); mapping.put("clearKey", nullSafeToString(alarm.getClearKey(), defaultMapping));