@Override public void flatMap(List<Object> input, Collector<Tuple2<String, AggregateEntity>> collector) { if (input.size() != 3) throw new IllegalStateException("AggregateExecutor always consumes exactly 3 fields: key, stream name and value(SortedMap)"); if (LOG.isDebugEnabled()) LOG.debug("Msg is coming " + input.get(2)); if (LOG.isDebugEnabled()) LOG.debug("Current policyEvaluators: " + evaluator); try { evaluator.evaluate(new ValuesArray(collector, input.get(1), input.get(2))); } catch (Exception ex) { LOG.error("Got an exception, but continue to run " + input.get(2).toString(), ex); } }
@Override public void onPolicyChanged(Map<String, T> changed) { if(LOG.isDebugEnabled()) LOG.debug(executorId + ", partition " + partitionSeq + " policy changed : " + changed); for(T alertDef : changed.values()){ if(!accept(alertDef)) continue; LOG.info(executorId + ", partition " + partitionSeq + " policy really changed " + alertDef); synchronized(this.policyEvaluators) { PolicyEvaluator<T> pe = policyEvaluators.get(alertDef.getTags().get(Constants.POLICY_ID)); boolean previousMarkdown = pe.isMarkdownEnabled(); String previousMarkdownReason = pe.getMarkdownReason(); pe.onPolicyUpdate(alertDef); if (isMarkdownUpdateRequired(previousMarkdown, pe.isMarkdownEnabled(), previousMarkdownReason, pe.getMarkdownReason())) updateMarkdownDetails(alertDef, pe.isMarkdownEnabled(), pe.getMarkdownReason()); } } }
String policyId = entry.getKey(); PolicyEvaluator<T> evaluator = entry.getValue(); if (!evaluator.isMarkdownEnabled()) { // not evaluated for a marked down policy updateCounter(EAGLE_POLICY_EVAL_COUNT, getDimensions(policyId)); try { evaluator.evaluate(new ValuesArray(outputCollector, input.get(1), input.get(2))); } catch (Exception ex) { LOG.error("Got an exception, but continue to run " + input.get(2).toString(), ex);
.getConstructor(Config.class, PolicyEvaluationContext.class, AbstractPolicyDefinition.class, String[].class, boolean.class) .newInstance(config, context, policyDef, sourceStreams, needValidation); if (pe.isMarkdownEnabled()) // updating markdown details only if the policy is found invalid updateMarkdownDetails(alertDef, pe.isMarkdownEnabled(), pe.getMarkdownReason()); } catch(Exception ex) { LOG.error("Fail creating new policyEvaluator", ex);
@Override public void onPolicyDeleted(Map<String, T> deleted) { if(LOG.isDebugEnabled()) LOG.debug(executorId + ", partition " + partitionSeq + " policy deleted : " + deleted); for(T alertDef : deleted.values()){ if(!accept(alertDef)) continue; LOG.info(executorId + ", partition " + partitionSeq + " policy really deleted " + alertDef); String policyId = alertDef.getTags().get(Constants.POLICY_ID); synchronized(this.policyEvaluators) { if (policyEvaluators.containsKey(policyId)) { PolicyEvaluator<T> pe = policyEvaluators.remove(alertDef.getTags().get(Constants.POLICY_ID)); pe.onPolicyDelete(); } } } }
tags.put(EagleConfigConstants.SITE, site); tags.put(EagleConfigConstants.APPLICATION, applicatioin); tags.put(Constants.SOURCE_STREAMS, (String)alertContext.evaluator.getAdditionalContext().get(Constants.SOURCE_STREAMS)); tags.put(Constants.POLICY_ID, alertContext.policyId); tags.put(Constants.ALERT_SOURCE, source);