@@ -0,0 +1,2375 @@
+package com.linkedin.thirdeye.detector.email.filter;%0A%0Aimport com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A%0A/**%0A * Created by ychung on 2/14/17.%0A *%0A * This WeightThresholdAlertFilter checks if the weight level of given merged anomaly result is between given up%0A * and down threshold. The up and down threshold should be positive floating point number. This class return false if%0A * - downThreshold %3C weight %3C upThreshold; otherwise, return true.%0A * Note that, down and up thresholds are supposed to be positive double value%0A */%0Apublic class WeightThresholdAlertFilter extends BaseAlertFilter %7B%0A  private final static Logger LOG = LoggerFactory.getLogger(WeightThresholdAlertFilter.class);%0A%0A  public static final String DEFAULT_UP_THRESHOLD = Double.toString(Double.POSITIVE_INFINITY);%0A  public static final String DEFAULT_DOWN_THRESHOLD = Double.toString(Double.POSITIVE_INFINITY);%0A%0A  public static final String UP_THRESHOLD = %22upThreshold%22;%0A  public static final String DOWN_THRESHOLD = %22downThreshold%22;%0A%0A  private double upThreshold = Double.parseDouble(DEFAULT_UP_THRESHOLD);%0A  private double dwnThreshold = Double.parseDouble(DEFAULT_DOWN_THRESHOLD);%0A%0A  public double getUpThreshold() %7B%0A    return upThreshold;%0A  %7D%0A%0A  public void setUpThreshold(double upThreshold) %7B%0A    this.upThreshold = Math.abs(upThreshold);%0A  %7D%0A%0A  public double getDownThreshold() %7B%0A    return dwnThreshold;%0A  %7D%0A%0A  public void setDownThreshold(double dwnThreshold) %7B%0A    this.dwnThreshold = Math.abs(dwnThreshold);%0A  %7D%0A%0A%0A  public WeightThresholdAlertFilter()%7B%0A%0A  %7D%0A%0A  public WeightThresholdAlertFilter(double upThreshold, double downThreshold)%7B%0A    setUpThreshold(upThreshold);%0A    setDownThreshold(downThreshold);%0A  %7D%0A%0A  @Override%0A  public List%3CString%3E getPropertyNames() %7B%0A    return Collections.unmodifiableList(new ArrayList%3C%3E(Arrays.asList(UP_THRESHOLD, DOWN_THRESHOLD)));%0A  %7D%0A%0A  // Check if the weight of the given MergedAnomalyResultDTO is greater or equal to the up threshold%0A  // or is less or equal to the down threshold.%0A  @Override%0A  public boolean isQualified(MergedAnomalyResultDTO anomaly) %7B%0A    double weight = anomaly.getWeight();%0A    return (weight %3E= upThreshold) %7C%7C (weight %3C= -1*dwnThreshold);%0A  %7D%0A%7D%0A

Implement an AlertFilter with up and down threshold (#1063)