use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.
the class TestAnomalyResultManager method testResultFeedback.
@Test(dependsOnMethods = { "testAnomalyResultCRUD" })
public void testResultFeedback() {
RawAnomalyResultDTO result = rawAnomalyResultDAO.findById(anomalyResult.getId());
Assert.assertNotNull(result);
Assert.assertNull(result.getFeedback());
AnomalyFeedbackDTO feedback = new AnomalyFeedbackDTO();
feedback.setComment("this is a good find");
feedback.setFeedbackType(AnomalyFeedbackType.ANOMALY);
feedback.setStatus(FeedbackStatus.NEW);
result.setFeedback(feedback);
rawAnomalyResultDAO.save(result);
RawAnomalyResultDTO resultRet = rawAnomalyResultDAO.findById(anomalyResult.getId());
Assert.assertEquals(resultRet.getId(), result.getId());
Assert.assertNotNull(resultRet.getFeedback());
AnomalyFunctionDTO functionSpec = result.getFunction();
rawAnomalyResultDAO.deleteById(anomalyResult.getId());
anomalyFunctionDAO.deleteById(functionSpec.getId());
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.
the class TestEmailConfigurationManager method testFunctionEmailAssignment.
@Test(dependsOnMethods = { "testCreateEmailConfig" })
public void testFunctionEmailAssignment() {
// create function
AnomalyFunctionDTO functionReq = getTestFunctionSpec("testMetric", "testCollection");
functionId = anomalyFunctionDAO.save(functionReq);
assertNotNull(functionId);
// save function in EmailConfig
EmailConfigurationDTO emailConfiguration = emailConfigurationDAO.findById(emailConfigId);
AnomalyFunctionDTO anomalyFunctionSpec = anomalyFunctionDAO.findById(functionId);
assertEquals(emailConfiguration.getFunctions().size(), 0);
List<AnomalyFunctionDTO> functionSpecList = new ArrayList<>();
functionSpecList.add(anomalyFunctionSpec);
emailConfiguration.setFunctions(functionSpecList);
emailConfigurationDAO.save(emailConfiguration);
// Validate relation in both Email and Function objects
EmailConfigurationDTO emailConfig1 = emailConfigurationDAO.findById(emailConfigId);
assertEquals(emailConfig1.getFunctions().size(), 1);
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.
the class TestAnomalyFunctionManager method testUpdate.
@Test(dependsOnMethods = { "testDistinctMetricsByCollection" })
public void testUpdate() {
AnomalyFunctionDTO spec = anomalyFunctionDAO.findById(anomalyFunctionId);
Assert.assertNotNull(spec);
Assert.assertEquals(spec.getMetricFunction(), MetricAggFunction.SUM);
spec.setMetricFunction(MetricAggFunction.COUNT);
anomalyFunctionDAO.save(spec);
AnomalyFunctionDTO specReturned = anomalyFunctionDAO.findById(anomalyFunctionId);
Assert.assertEquals(specReturned.getMetricFunction(), MetricAggFunction.COUNT);
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.
the class RunAdhocDatabaseQueriesTool method disableAnomalyFunctions.
private void disableAnomalyFunctions(String dataset) {
List<AnomalyFunctionDTO> anomalyFunctionDTOs = anomalyFunctionDAO.findAllByCollection(dataset);
for (AnomalyFunctionDTO anomalyFunctionDTO : anomalyFunctionDTOs) {
anomalyFunctionDTO.setActive(false);
anomalyFunctionDAO.update(anomalyFunctionDTO);
}
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.
the class FetchMetricDataAndExistingAnomaliesTool method fetchRawAnomaliesInRange.
/**
* Fetch raw anomaly results from thirdeye db
* @param collection database/collection name
* @param metric metric name
* @param startTime start time of the requested data in DateTime format
* @param endTime end time of the requested data in DateTime format
* @return List of raw anomaly results
*/
public List<ResultNode> fetchRawAnomaliesInRange(String collection, String metric, DateTime startTime, DateTime endTime) {
List<AnomalyFunctionDTO> anomalyFunctions = anomalyFunctionDAO.findAllByCollection(collection);
LOG.info("Loading raw anaomaly results from db...");
List<ResultNode> resultNodes = new ArrayList<>();
for (AnomalyFunctionDTO anomalyDto : anomalyFunctions) {
if (!anomalyDto.getTopicMetric().equals(metric))
continue;
long id = anomalyDto.getId();
resultNodes.addAll(fetchRawAnomaliesInRangeByFunctionId(id, startTime, endTime));
}
Collections.sort(resultNodes);
return resultNodes;
}
Aggregations