public static boolean accept(AlertDefinitionAPIEntity alertDef, PolicyPartitioner partitioner, int numPartitions, int partitionSeq){ int targetPartitionSeq = partitioner.partition(numPartitions, alertDef.getTags().get(Constants.POLICY_TYPE), alertDef.getTags().get(Constants.POLICY_ID)); if(targetPartitionSeq == partitionSeq) return true; return false; } }
/** * verify both alertExecutor logic name and partition id * @param alertDef alert definition * * @return whether accept the alert definition */ private boolean accept(T alertDef){ String executorID = alertDef.getTags().containsKey("executorId") ? alertDef.getTags().get("executorId") : alertDef.getTags().get("alertExecutorId"); if(!executorID.equals(executorId)) { if(LOG.isDebugEnabled()){ LOG.debug("alertDef does not belong to this alertExecutorId : " + executorId + ", alertDef : " + alertDef); } return false; } int targetPartitionSeq = partitioner.partition(numPartitions, alertDef.getTags().get(Constants.POLICY_TYPE), alertDef.getTags().get(Constants.POLICY_ID)); if(targetPartitionSeq == partitionSeq) return true; return false; }
int part = partitioner.partition(numPartitions, alertDef.getTags().get(Constants.POLICY_TYPE), alertDef.getTags().get(Constants.POLICY_ID)); if (part == partitionSeq) { tmpPolicyEvaluators.put(alertDef.getTags().get(Constants.POLICY_ID), createPolicyEvaluator(alertDef));