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 2019/03/19 23:40:52 UTC
[incubator-pinot] branch master updated: [TE] Remove deprecated
legacy logic in user dashboard (#3988)
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 f26b2f3 [TE] Remove deprecated legacy logic in user dashboard (#3988)
f26b2f3 is described below
commit f26b2f3d3855db351db2b9d3a7ec69de7c1a3b51
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Tue Mar 19 16:40:47 2019 -0700
[TE] Remove deprecated legacy logic in user dashboard (#3988)
---
.../api/user/dashboard/UserDashboardResource.java | 140 +--------------------
.../dashboard/ThirdEyeDashboardApplication.java | 3 +-
.../resources/v2/pojo/AnomalySummary.java | 9 --
.../resource/v2/UserDashboardResourceTest.java | 97 +++++++-------
4 files changed, 60 insertions(+), 189 deletions(-)
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/api/user/dashboard/UserDashboardResource.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/api/user/dashboard/UserDashboardResource.java
index 871f34a..e2d7fc8 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/api/user/dashboard/UserDashboardResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/api/user/dashboard/UserDashboardResource.java
@@ -27,13 +27,8 @@ import com.wordnik.swagger.annotations.ApiParam;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -46,18 +41,14 @@ import javax.ws.rs.core.MediaType;
import org.apache.commons.lang.StringUtils;
import org.apache.pinot.thirdeye.api.Constants;
import org.apache.pinot.thirdeye.constant.AnomalyFeedbackType;
-import org.apache.pinot.thirdeye.constant.AnomalyResultSource;
import org.apache.pinot.thirdeye.dashboard.resources.v2.ResourceUtils;
import org.apache.pinot.thirdeye.dashboard.resources.v2.pojo.AnomalySummary;
import org.apache.pinot.thirdeye.datalayer.bao.AlertConfigManager;
-import org.apache.pinot.thirdeye.datalayer.bao.AnomalyFunctionManager;
import org.apache.pinot.thirdeye.datalayer.bao.DatasetConfigManager;
import org.apache.pinot.thirdeye.datalayer.bao.DetectionAlertConfigManager;
import org.apache.pinot.thirdeye.datalayer.bao.DetectionConfigManager;
import org.apache.pinot.thirdeye.datalayer.bao.MergedAnomalyResultManager;
import org.apache.pinot.thirdeye.datalayer.bao.MetricConfigManager;
-import org.apache.pinot.thirdeye.datalayer.dto.AlertConfigDTO;
-import org.apache.pinot.thirdeye.datalayer.dto.AnomalyFunctionDTO;
import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
import org.apache.pinot.thirdeye.datalayer.dto.DetectionConfigDTO;
import org.apache.pinot.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
@@ -65,14 +56,11 @@ import org.apache.pinot.thirdeye.datalayer.util.Predicate;
import org.apache.pinot.thirdeye.datasource.ThirdEyeCacheRegistry;
import org.apache.pinot.thirdeye.datasource.loader.AggregationLoader;
import org.apache.pinot.thirdeye.datasource.loader.DefaultAggregationLoader;
-import org.apache.pinot.thirdeye.detection.ConfigUtils;
import org.apache.pinot.thirdeye.detection.CurrentAndBaselineLoader;
import org.apache.pinot.thirdeye.rootcause.impl.MetricEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.thirdeye.detection.yaml.YamlDetectionAlertConfigTranslator.*;
-
/**
* Endpoints for user-customized dashboards (currently alerts only)
@@ -86,8 +74,6 @@ public class UserDashboardResource {
private static final int ANOMALIES_LIMIT_DEFAULT = 500;
private final MergedAnomalyResultManager anomalyDAO;
- private final AnomalyFunctionManager functionDAO;
- private final AlertConfigManager alertDAO;
private final MetricConfigManager metricDAO;
private final DatasetConfigManager datasetDAO;
private final DetectionConfigManager detectionDAO;
@@ -96,14 +82,12 @@ public class UserDashboardResource {
private final CurrentAndBaselineLoader currentAndBaselineLoader;
- public UserDashboardResource(MergedAnomalyResultManager anomalyDAO, AnomalyFunctionManager functionDAO,
- MetricConfigManager metricDAO, DatasetConfigManager datasetDAO, AlertConfigManager alertDAO,
- DetectionConfigManager detectionDAO, DetectionAlertConfigManager detectionAlertDAO) {
+ public UserDashboardResource(MergedAnomalyResultManager anomalyDAO, MetricConfigManager metricDAO,
+ DatasetConfigManager datasetDAO, DetectionConfigManager detectionDAO,
+ DetectionAlertConfigManager detectionAlertDAO) {
this.anomalyDAO = anomalyDAO;
- this.functionDAO = functionDAO;
this.metricDAO = metricDAO;
this.datasetDAO = datasetDAO;
- this.alertDAO = alertDAO;
this.detectionDAO = detectionDAO;
this.detectionAlertDAO = detectionAlertDAO;
@@ -188,7 +172,6 @@ public class UserDashboardResource {
// TODO: Prefer to have intersection of anomalies rather than union
List<MergedAnomalyResultDTO> anomalies = new ArrayList<>();
- anomalies.addAll(fetchLegacyAnomaliesByFunctionId(start, end, group, application, owner));
// Fetch anomalies by group
anomalies.addAll(fetchAnomaliesBySubsGroup(start, end, group));
// Fetch anomalies by application
@@ -197,12 +180,7 @@ public class UserDashboardResource {
anomalies.addAll(fetchAnomaliesByMetricDataset(start, end, metric, dataset));
// sort descending by start time
- Collections.sort(anomalies, new Comparator<MergedAnomalyResultDTO>() {
- @Override
- public int compare(MergedAnomalyResultDTO o1, MergedAnomalyResultDTO o2) {
- return -1 * Long.compare(o1.getStartTime(), o2.getStartTime());
- }
- });
+ Collections.sort(anomalies, (o1, o2) -> -1 * Long.compare(o1.getStartTime(), o2.getStartTime()));
if (fetchTrueAnomaly) {
// Filter and retain only true anomalies
@@ -228,19 +206,6 @@ public class UserDashboardResource {
private List<AnomalySummary> getAnomalyFormattedOutput(List<MergedAnomalyResultDTO> anomalies) {
List<AnomalySummary> output = new ArrayList<>();
- // fetch functions & build function id to function object mapping
- Set<Long> anomalyFunctionIds = new HashSet<>();
- for (MergedAnomalyResultDTO anomaly : anomalies) {
- if (anomaly.getFunctionId() != null) {
- anomalyFunctionIds.add(anomaly.getFunctionId());
- }
- }
- List<AnomalyFunctionDTO> functions = this.functionDAO.findByPredicate(Predicate.IN("baseId", anomalyFunctionIds.toArray()));
- Map<Long, AnomalyFunctionDTO> id2function = new HashMap<>();
- for (AnomalyFunctionDTO function : functions) {
- id2function.put(function.getId(), function);
- }
-
for (MergedAnomalyResultDTO anomaly : anomalies) {
long metricId = this.getMetricId(anomaly);
@@ -251,14 +216,6 @@ public class UserDashboardResource {
summary.setCurrent(anomaly.getAvgCurrentVal());
summary.setBaseline(anomaly.getAvgBaselineVal());
- summary.setFunctionId(-1);
- if (anomaly.getFunctionId() != null) {
- summary.setFunctionId(anomaly.getFunctionId());
- if (id2function.get(anomaly.getFunctionId()) != null) {
- summary.setFunctionName(id2function.get(anomaly.getFunctionId()).getFunctionName());
- }
- }
-
summary.setDetectionConfigId(-1);
if (anomaly.getDetectionConfigId() != null) {
long detectionConfigId = anomaly.getDetectionConfigId();
@@ -296,95 +253,6 @@ public class UserDashboardResource {
return output;
}
- @Deprecated
- private Collection<MergedAnomalyResultDTO> fetchLegacyAnomaliesByFunctionId(Long start, Long end, String group, String application, String owner) {
- // Find functionIds which belong to application, subscription group and owner.
- List<Predicate> predicates = new ArrayList<>();
- Set<Long> functionIds = new HashSet<>();
-
- // application (indirect)
- if (StringUtils.isNotBlank(application)) {
- List<AnomalyFunctionDTO> functions = this.functionDAO.findAllByApplication(application);
- for (AnomalyFunctionDTO function : functions) {
- if (function.getIsActive()) {
- functionIds.add(function.getId());
- }
- }
- }
- // Support for partially migrated alerts.
- List<DetectionAlertConfigDTO> notifications = detectionAlertDAO.findByPredicate(Predicate.EQ("application", application));
- for (DetectionAlertConfigDTO notification : notifications) {
- for (long id : ConfigUtils.getLongs(notification.getProperties().get(PROP_DETECTION_CONFIG_IDS))) {
- AnomalyFunctionDTO function = this.functionDAO.findById(id);
- if (function != null && function.getIsActive()) {
- functionIds.add(id);
- }
- }
- }
-
- // group (indirect)
- Set<Long> groupFunctionIds = new HashSet<>();
- if (StringUtils.isNotBlank(group)) {
- AlertConfigDTO alert = this.alertDAO.findWhereNameEquals(group);
- if (alert != null) {
- for (long id : alert.getEmailConfig().getFunctionIds()) {
- AnomalyFunctionDTO function = this.functionDAO.findById(id);
- if (function != null && function.getIsActive()) {
- groupFunctionIds.add(id);
- }
- }
- }
- }
- if (!groupFunctionIds.isEmpty()) {
- if (functionIds.isEmpty()) {
- functionIds = groupFunctionIds;
- } else {
- functionIds.retainAll(groupFunctionIds);
- }
- }
-
- // owner (indirect)
- Set<Long> ownerFunctionIds = new HashSet<>();
- if (StringUtils.isNotBlank(owner)) {
- // TODO: replace database scan with targeted select
- List<AnomalyFunctionDTO> functions = this.functionDAO.findAll();
- for (AnomalyFunctionDTO function : functions) {
- if (function.getIsActive() && Objects.equals(function.getCreatedBy(), owner)) {
- ownerFunctionIds.add(function.getId());
- }
- }
- }
- if (!ownerFunctionIds.isEmpty()) {
- if (functionIds.isEmpty()) {
- functionIds = ownerFunctionIds;
- } else {
- functionIds.retainAll(ownerFunctionIds);
- }
- }
-
- // Predicate on start time end time and function Id.
- predicates.add(Predicate.IN("functionId", functionIds.toArray()));
- predicates.add(Predicate.GE("endTime", start));
- if (end != null) {
- predicates.add(Predicate.LT("startTime", end));
- }
-
- // Fetch legacy anomalies via predicates
- List<MergedAnomalyResultDTO> anomalies = this.anomalyDAO.findByPredicate(Predicate.AND(predicates.toArray(new Predicate[predicates.size()])));
- // filter (un-notified && non-user-reported) anomalies
- // TODO remove once index select on user-reported anomalies available
- Iterator<MergedAnomalyResultDTO> itAnomaly = anomalies.iterator();
- while (itAnomaly.hasNext()) {
- MergedAnomalyResultDTO anomaly = itAnomaly.next();
- if (!anomaly.isNotified() &&
- !AnomalyResultSource.USER_LABELED_ANOMALY.equals(anomaly.getAnomalyResultSource())) {
- itAnomaly.remove();
- }
- }
-
- return anomalies;
- }
-
private Collection<MergedAnomalyResultDTO> fetchAnomaliesByMetricDataset(Long start, Long end, String metric, String dataset) {
if (StringUtils.isBlank(metric) && StringUtils.isBlank(dataset)) {
return Collections.emptyList();
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/ThirdEyeDashboardApplication.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/ThirdEyeDashboardApplication.java
index d4ffcf4..7eba9fd 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/ThirdEyeDashboardApplication.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/ThirdEyeDashboardApplication.java
@@ -185,8 +185,7 @@ public class ThirdEyeDashboardApplication
env.jersey().register(new CustomizedEventResource(DAO_REGISTRY.getEventDAO()));
env.jersey().register(new TimeSeriesResource());
env.jersey().register(new UserDashboardResource(
- DAO_REGISTRY.getMergedAnomalyResultDAO(), DAO_REGISTRY.getAnomalyFunctionDAO(),
- DAO_REGISTRY.getMetricConfigDAO(), DAO_REGISTRY.getDatasetConfigDAO(), DAO_REGISTRY.getAlertConfigDAO(),
+ DAO_REGISTRY.getMergedAnomalyResultDAO(), DAO_REGISTRY.getMetricConfigDAO(), DAO_REGISTRY.getDatasetConfigDAO(),
DAO_REGISTRY.getDetectionConfigManager(), DAO_REGISTRY.getDetectionAlertConfigManager()));
env.jersey().register(new ApplicationResource(
DAO_REGISTRY.getApplicationDAO(), DAO_REGISTRY.getMergedAnomalyResultDAO(),
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/pojo/AnomalySummary.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/pojo/AnomalySummary.java
index 9e7deb2..38a5089 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/pojo/AnomalySummary.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/pojo/AnomalySummary.java
@@ -41,7 +41,6 @@ public class AnomalySummary {
private String metricUrn;
private long metricId;
private String functionName;
- private long functionId;
private String dataset;
private AnomalyClassificationType classification;
private AnomalyResultSource source;
@@ -147,14 +146,6 @@ public class AnomalySummary {
this.metricUrn = metricUrn;
}
- public long getFunctionId() {
- return functionId;
- }
-
- public void setFunctionId(long functionId) {
- this.functionId = functionId;
- }
-
public String getDataset() {
return dataset;
}
diff --git a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/dashboard/resource/v2/UserDashboardResourceTest.java b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/dashboard/resource/v2/UserDashboardResourceTest.java
index 3f97f7c..a64a331 100644
--- a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/dashboard/resource/v2/UserDashboardResourceTest.java
+++ b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/dashboard/resource/v2/UserDashboardResourceTest.java
@@ -1,12 +1,10 @@
package org.apache.pinot.thirdeye.dashboard.resource.v2;
-import org.apache.pinot.thirdeye.anomalydetection.context.AnomalyFeedback;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.pinot.thirdeye.api.user.dashboard.UserDashboardResource;
-import org.apache.pinot.thirdeye.common.dimension.DimensionMap;
-import org.apache.pinot.thirdeye.constant.AnomalyFeedbackType;
import org.apache.pinot.thirdeye.dashboard.resources.v2.pojo.AnomalySummary;
import org.apache.pinot.thirdeye.datalayer.bao.AlertConfigManager;
-import org.apache.pinot.thirdeye.datalayer.bao.AnomalyFunctionManager;
import org.apache.pinot.thirdeye.datalayer.bao.DAOTestBase;
import org.apache.pinot.thirdeye.datalayer.bao.DatasetConfigManager;
import org.apache.pinot.thirdeye.datalayer.bao.DetectionAlertConfigManager;
@@ -14,9 +12,11 @@ import org.apache.pinot.thirdeye.datalayer.bao.DetectionConfigManager;
import org.apache.pinot.thirdeye.datalayer.bao.MergedAnomalyResultManager;
import org.apache.pinot.thirdeye.datalayer.bao.MetricConfigManager;
import org.apache.pinot.thirdeye.datalayer.dto.AlertConfigDTO;
-import org.apache.pinot.thirdeye.datalayer.dto.AnomalyFeedbackDTO;
-import org.apache.pinot.thirdeye.datalayer.dto.AnomalyFunctionDTO;
+import org.apache.pinot.thirdeye.datalayer.dto.DatasetConfigDTO;
+import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+import org.apache.pinot.thirdeye.datalayer.dto.DetectionConfigDTO;
import org.apache.pinot.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
+import org.apache.pinot.thirdeye.datalayer.dto.MetricConfigDTO;
import org.apache.pinot.thirdeye.datalayer.pojo.AlertConfigBean;
import org.apache.pinot.thirdeye.datasource.DAORegistry;
import java.util.ArrayList;
@@ -37,15 +37,13 @@ public class UserDashboardResourceTest {
UserDashboardResource resource;
MergedAnomalyResultManager anomalyDAO;
- AnomalyFunctionManager functionDAO;
- AlertConfigManager alertDAO;
DetectionConfigManager detectionDAO;
DetectionAlertConfigManager detectionAlertDAO;
MetricConfigManager metricDAO;
DatasetConfigManager datasetDAO;
List<Long> anomalyIds;
- List<Long> functionIds;
+ List<Long> detectionIds;
List<Long> alertIds;
@BeforeMethod
@@ -54,39 +52,43 @@ public class UserDashboardResourceTest {
// metrics
this.metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
+ long metricid = this.metricDAO.save(makeMetric("test_metric", "test_dataset"));
+ this.metricDAO.save(makeMetric("test_metric_2", "test_dataset"));
// datasets
this.datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
+ this.datasetDAO.save(makeDataset("test_dataset"));
- // functions
- this.functionDAO = DAORegistry.getInstance().getAnomalyFunctionDAO();
- this.functionIds = new ArrayList<>();
- this.functionIds.add(this.functionDAO.save(makeFunction("myFunctionA")));
- this.functionIds.add(this.functionDAO.save(makeFunction("myFunctionB")));
- this.functionIds.add(this.functionDAO.save(makeFunction("myFunctionC")));
+ // detections
+ this.detectionDAO = DAORegistry.getInstance().getDetectionConfigManager();
+ this.detectionIds = new ArrayList<>();
+ this.detectionIds.add(this.detectionDAO.save(makeDetection("myDetectionA")));
+ this.detectionIds.add(this.detectionDAO.save(makeDetection("myDetectionB")));
+ this.detectionIds.add(this.detectionDAO.save(makeDetection("myDetectionC")));
- for (Long id : this.functionIds) {
+ for (Long id : this.detectionIds) {
Assert.assertNotNull(id);
}
// anomalies
this.anomalyDAO = DAORegistry.getInstance().getMergedAnomalyResultDAO();
+ this.anomalyDAO = DAORegistry.getInstance().getMergedAnomalyResultDAO();
this.anomalyIds = new ArrayList<>();
- this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(100, 500, this.functionIds.get(0), "test_metric", "test_dataset"))); // func A
- this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(800, 1200, this.functionIds.get(0), "test_metric", "test_dataset"))); // func A
- this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(300, 1500, this.functionIds.get(1), "test_metric", "test_dataset"))); // func B
- this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(300, 1600, this.functionIds.get(2), "test_metric", "test_dataset"))); // func C
- this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(300, 1600, this.functionIds.get(2), "test_metric_2", "test_dataset"))); // func C
+ this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(100, 500, this.detectionIds.get(0), "test_metric", "test_dataset"))); // myDetectionA
+ this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(800, 1200, this.detectionIds.get(0), "test_metric", "test_dataset"))); // myDetectionA
+ this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(300, 1500, this.detectionIds.get(1), "test_metric", "test_dataset"))); // myDetectionB
+ this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(300, 1600, this.detectionIds.get(2), "test_metric", "test_dataset"))); // myDetectionC
+ this.anomalyIds.add(this.anomalyDAO.save(makeAnomaly(300, 1600, this.detectionIds.get(2), "test_metric_2", "test_dataset"))); // myDetectionC
for (Long id : this.anomalyIds) {
Assert.assertNotNull(id);
}
// alerts
- this.alertDAO = DAORegistry.getInstance().getAlertConfigDAO();
+ this.detectionAlertDAO = DAORegistry.getInstance().getDetectionAlertConfigManager();
this.alertIds = new ArrayList<>();
- this.alertIds.add(this.alertDAO.save(makeAlert("myAlertA", "myApplicationA", Arrays.asList(this.functionIds.get(0), this.functionIds.get(1))))); // funcA, funcB
- this.alertIds.add(this.alertDAO.save(makeAlert("myAlertB", "myApplicationB", Collections.singletonList(this.functionIds.get(2))))); // none
+ this.alertIds.add(this.detectionAlertDAO.save(makeAlert("myAlertA", "myApplicationA", Arrays.asList(this.detectionIds.get(0), this.detectionIds.get(1))))); // myDetectionA, myDetectionB
+ this.alertIds.add(this.detectionAlertDAO.save(makeAlert("myAlertB", "myApplicationB", Collections.singletonList(this.detectionIds.get(2))))); // none
for (Long id : this.alertIds) {
Assert.assertNotNull(id);
@@ -95,11 +97,8 @@ public class UserDashboardResourceTest {
// new framework detectors
this.detectionDAO = DAORegistry.getInstance().getDetectionConfigManager();
- // new framework alerts
- this.detectionAlertDAO = DAORegistry.getInstance().getDetectionAlertConfigManager();
-
// resource
- this.resource = new UserDashboardResource(this.anomalyDAO, this.functionDAO, this.metricDAO, this.datasetDAO, this.alertDAO, this.detectionDAO, this.detectionAlertDAO);
+ this.resource = new UserDashboardResource(this.anomalyDAO, this.metricDAO, this.datasetDAO, this.detectionDAO, this.detectionAlertDAO);
}
@AfterMethod(alwaysRun = true)
@@ -156,32 +155,46 @@ public class UserDashboardResourceTest {
Assert.assertEquals(extractIds(anomalies), makeSet(this.anomalyIds.get(1), this.anomalyIds.get(2), this.anomalyIds.get(3), this.anomalyIds.get(4)));
}
- private MergedAnomalyResultDTO makeAnomaly(long start, long end, Long functionId, String metric, String dataset) {
+ private MergedAnomalyResultDTO makeAnomaly(long start, long end, Long detectionId, String metric, String dataset) {
MergedAnomalyResultDTO anomaly = new MergedAnomalyResultDTO();
anomaly.setStartTime(start);
anomaly.setEndTime(end);
anomaly.setMetric(metric);
anomaly.setCollection(dataset);
- anomaly.setFunctionId(functionId);
+ anomaly.setDetectionConfigId(detectionId);
anomaly.setNotified(true);
return anomaly;
}
- private AnomalyFunctionDTO makeFunction(String name) {
- AnomalyFunctionDTO function = new AnomalyFunctionDTO();
- function.setFunctionName(name);
- return function;
+ private DetectionConfigDTO makeDetection(String name) {
+ DetectionConfigDTO detection = new DetectionConfigDTO();
+ detection.setName(name);
+ return detection;
+ }
+
+ private MetricConfigDTO makeMetric(String metricName, String datasetName) {
+ MetricConfigDTO metric = new MetricConfigDTO();
+ metric.setName(metricName);
+ metric.setDataset(datasetName);
+ metric.setAlias(metricName + "::" + datasetName);
+ return metric;
+ }
+
+ private DatasetConfigDTO makeDataset(String name) {
+ DatasetConfigDTO dataset = new DatasetConfigDTO();
+ dataset.setDataset(name);
+ return dataset;
}
- private AlertConfigDTO makeAlert(String name, String application, List<Long> functionIds) {
- AlertConfigBean.EmailConfig emailConfig = new AlertConfigBean.EmailConfig();
- emailConfig.setFunctionIds(functionIds);
+ private DetectionAlertConfigDTO makeAlert(String name, String application, List<Long> detectionIds) {
+ DetectionAlertConfigDTO notification = new DetectionAlertConfigDTO();
+ notification.setName(name);
+ notification.setApplication(application);
- AlertConfigDTO alert = new AlertConfigDTO();
- alert.setName(name);
- alert.setApplication(application);
- alert.setEmailConfig(emailConfig);
- return alert;
+ Map<Long, Long> vectorClocks = new HashMap<>();
+ detectionIds.forEach(id -> vectorClocks.put(id, 0l));
+ notification.setVectorClocks(vectorClocks);
+ return notification;
}
private Set<Long> extractIds(Collection<AnomalySummary> anomalies) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org