akshayrai closed pull request #3580: [TE] Support sendOnce in LegacyAlertFilter
URL: https://github.com/apache/incubator-pinot/pull/3580
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilter.java
index 886b7b7137..863e71ecf5 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilter.java
@@ -50,15 +50,18 @@
   private static final String PROP_TO = "to";
   private static final String PROP_CC = "cc";
   private static final String PROP_BCC = "bcc";
+  private static final String PROP_SEND_ONCE = "sendOnce";
 
   private final List<Long> detectionConfigIds;
   private final Map<Long, Long> vectorClocks;
+  private final boolean sendOnce;
 
   public LegacyAlertFilter(DataProvider provider, DetectionAlertConfigDTO 
config, long endTime) throws Exception {
     super(provider, config, endTime);
 
     this.detectionConfigIds = 
ConfigUtils.getLongs(this.config.getProperties().get(PROP_DETECTION_CONFIG_IDS));
     this.vectorClocks = this.config.getVectorClocks();
+    this.sendOnce = MapUtils.getBoolean(this.config.getProperties(), 
PROP_SEND_ONCE, true);
   }
 
   @Override
@@ -103,11 +106,15 @@ public DetectionAlertFilterResult run() throws Exception {
       }
 
       BaseAlertFilter finalAlertFilter = alertFilter;
+      final long minId = getMinId(this.config.getHighWaterMark());
       Collection<MergedAnomalyResultDTO> anomalies =
           Collections2.filter(candidates, new 
Predicate<MergedAnomalyResultDTO>() {
             @Override
             public boolean apply(@Nullable MergedAnomalyResultDTO 
mergedAnomaly) {
-              return mergedAnomaly != null && !mergedAnomaly.isChild() && 
finalAlertFilter.isQualified(mergedAnomaly);
+              return mergedAnomaly != null
+                      && !mergedAnomaly.isChild()
+                      && finalAlertFilter.isQualified(mergedAnomaly)
+                      && (mergedAnomaly.getId() == null || 
mergedAnomaly.getId() >= minId);
             }
           });
 
@@ -120,4 +127,12 @@ public boolean apply(@Nullable MergedAnomalyResultDTO 
mergedAnomaly) {
 
     return result;
   }
+
+  private long getMinId(long highWaterMark) {
+    if (this.sendOnce) {
+      return highWaterMark + 1;
+    } else {
+      return 0;
+    }
+  }
 }
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilterTest.java
index 166e83432d..6777014996 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/com/linkedin/thirdeye/detection/alert/filter/LegacyAlertFilterTest.java
@@ -88,6 +88,7 @@ private DetectionAlertConfigDTO createDetectionAlertConfig() {
     properties.put(PROP_LEGACY_ALERT_FILTER_CLASS_NAME, 
"com.linkedin.thirdeye.detector.email.filter.DummyAlertFilter");
     properties.put(PROP_LEGACY_ALERT_FILTER_CONFIG, "");
     properties.put(PROP_RECIPIENTS, recipientsMap);
+    detectionAlertConfig.setHighWaterMark(0L);
     detectionAlertConfig.setProperties(properties);
     detectionAlertConfig.setVectorClocks(new HashMap<Long, Long>());
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to