Search in sources :

Example 41 with AnomalyFunctionDTO

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());
}
Also used : RawAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO) AnomalyFeedbackDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) Test(org.testng.annotations.Test)

Example 42 with AnomalyFunctionDTO

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);
}
Also used : ArrayList(java.util.ArrayList) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) Test(org.testng.annotations.Test)

Example 43 with AnomalyFunctionDTO

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);
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) Test(org.testng.annotations.Test)

Example 44 with AnomalyFunctionDTO

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);
    }
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Example 45 with 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;
}
Also used : ArrayList(java.util.ArrayList) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Aggregations

AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)74 ArrayList (java.util.ArrayList)23 DateTime (org.joda.time.DateTime)20 RawAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO)19 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)17 Test (org.testng.annotations.Test)16 Path (javax.ws.rs.Path)11 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)9 POST (javax.ws.rs.POST)8 AnomalyDetectionContext (com.linkedin.thirdeye.anomalydetection.context.AnomalyDetectionContext)7 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)7 EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)7 AnomalyFunctionBean (com.linkedin.thirdeye.datalayer.pojo.AnomalyFunctionBean)6 Interval (org.joda.time.Interval)6 MetricTimeSeries (com.linkedin.thirdeye.api.MetricTimeSeries)5 AnomalyFeedbackDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO)5 DetectionStatusDTO (com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO)5 ScalingFactor (com.linkedin.thirdeye.detector.metric.transfer.ScalingFactor)5 HashMap (java.util.HashMap)5 NullArgumentException (org.apache.commons.lang.NullArgumentException)5