@Override public void onPolicyCreated(Map<String, T> added) { if(LOG.isDebugEnabled()) LOG.debug(executorId + ", partition " + partitionSeq + " policy added : " + added + " policyEvaluators " + policyEvaluators); for(T alertDef : added.values()){ if(!accept(alertDef)) continue; LOG.info(executorId + ", partition " + partitionSeq + " policy really added " + alertDef); PolicyEvaluator<T> newEvaluator = createPolicyEvaluator(alertDef); if(newEvaluator != null){ synchronized(this.policyEvaluators) { policyEvaluators.put(alertDef.getTags().get(Constants.POLICY_ID), newEvaluator); } } } }
@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(); } } } }
@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()); } } }