You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2018/12/04 00:43:03 UTC
[incubator-pinot] branch master updated: [TE] Support sendOnce in
LegacyAlertFilter (#3580)
This is an automated email from the ASF dual-hosted git repository.
akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 5067baf [TE] Support sendOnce in LegacyAlertFilter (#3580)
5067baf is described below
commit 5067baf2679a61ffbcb7d7dee8eb5641b0356bf6
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Mon Dec 3 16:42:57 2018 -0800
[TE] Support sendOnce in LegacyAlertFilter (#3580)
---
.../detection/alert/filter/LegacyAlertFilter.java | 17 ++++++++++++++++-
.../detection/alert/filter/LegacyAlertFilterTest.java | 1 +
2 files changed, 17 insertions(+), 1 deletion(-)
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 886b7b7..863e71e 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 @@ public class LegacyAlertFilter extends DetectionAlertFilter {
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 class LegacyAlertFilter extends DetectionAlertFilter {
}
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 class LegacyAlertFilter extends DetectionAlertFilter {
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 166e834..6777014 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 @@ public class LegacyAlertFilterTest {
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>());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org