Search in sources :

Example 6 with DetectionStatusDTO

use of com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO in project pinot by linkedin.

the class RunAdhocDatabaseQueriesTool method updateDetectionRun.

private void updateDetectionRun(String dataset) {
    for (DetectionStatusDTO dto : detectionStatusDAO.findAll()) {
        if (dto.getDataset().equals(dataset)) {
            dto.setDetectionRun(false);
            detectionStatusDAO.update(dto);
        }
    }
}
Also used : DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO)

Example 7 with DetectionStatusDTO

use of com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO in project pinot by linkedin.

the class TestDetectionStatusManager method testCreate.

@Test
public void testCreate() {
    String dateString = dateTimeFormatter.print(now.getMillis());
    long dateMillis = dateTimeFormatter.parseMillis(dateString);
    detectionStatusId1 = detectionStatusDAO.save(getTestDetectionStatus(collection1, dateMillis, dateString, false, 1));
    detectionStatusDAO.save(getTestDetectionStatus(collection1, dateMillis, dateString, true, 2));
    dateMillis = new DateTime(dateMillis).minusHours(1).getMillis();
    dateString = dateTimeFormatter.print(dateMillis);
    detectionStatusId2 = detectionStatusDAO.save(getTestDetectionStatus(collection1, dateMillis, dateString, true, 1));
    detectionStatusDAO.save(getTestDetectionStatus(collection1, dateMillis, dateString, true, 2));
    dateMillis = new DateTime(dateMillis).minusHours(1).getMillis();
    dateString = dateTimeFormatter.print(dateMillis);
    detectionStatusDAO.save(getTestDetectionStatus(collection1, dateMillis, dateString, true, 2));
    Assert.assertNotNull(detectionStatusId1);
    Assert.assertNotNull(detectionStatusId2);
    List<DetectionStatusDTO> detectionStatusDTOs = detectionStatusDAO.findAll();
    Assert.assertEquals(detectionStatusDTOs.size(), 5);
}
Also used : DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 8 with DetectionStatusDTO

use of com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO in project pinot by linkedin.

the class TestDetectionStatusManager method testFind.

@Test(dependsOnMethods = { "testCreate" })
public void testFind() {
    DetectionStatusDTO detectionStatusDTO = detectionStatusDAO.findLatestEntryForFunctionId(1);
    String dateString = dateTimeFormatter.print(now.getMillis());
    Assert.assertEquals(detectionStatusDTO.getFunctionId(), 1);
    Assert.assertEquals(detectionStatusDTO.getDateToCheckInSDF(), dateString);
    Assert.assertEquals(detectionStatusDTO.isDetectionRun(), false);
    long dateMillis = dateTimeFormatter.parseMillis(dateString);
    dateMillis = new DateTime(dateMillis).minusHours(1).getMillis();
    List<DetectionStatusDTO> detectionStatusDTOs = detectionStatusDAO.findAllInTimeRangeForFunctionAndDetectionRun(dateMillis, now.getMillis(), 2, true);
    Assert.assertEquals(detectionStatusDTOs.size(), 2);
    detectionStatusDTOs = detectionStatusDAO.findAllInTimeRangeForFunctionAndDetectionRun(dateMillis, now.getMillis(), 2, false);
    Assert.assertEquals(detectionStatusDTOs.size(), 0);
}
Also used : DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 9 with DetectionStatusDTO

use of com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO in project pinot by linkedin.

the class AbstractManagerTestBase method getTestDetectionStatus.

protected DetectionStatusDTO getTestDetectionStatus(String dataset, long dateToCheckInMS, String dateToCheckInSDF, boolean detectionRun, long functionId) {
    DetectionStatusDTO detectionStatusDTO = new DetectionStatusDTO();
    detectionStatusDTO.setDataset(dataset);
    detectionStatusDTO.setFunctionId(functionId);
    detectionStatusDTO.setDateToCheckInMS(dateToCheckInMS);
    detectionStatusDTO.setDateToCheckInSDF(dateToCheckInSDF);
    detectionStatusDTO.setDetectionRun(detectionRun);
    return detectionStatusDTO;
}
Also used : DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO)

Example 10 with DetectionStatusDTO

use of com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO in project pinot by linkedin.

the class TestDetectionJobSchedulerUtils method testGetNewEntriesForDetectionSchedulerMinuteLevel.

@Test
public void testGetNewEntriesForDetectionSchedulerMinuteLevel() throws Exception {
    DatasetConfigDTO datasetConfig = new DatasetConfigDTO();
    datasetConfig.setTimeColumn("Date");
    datasetConfig.setTimeUnit(TimeUnit.MINUTES);
    datasetConfig.setTimeDuration(5);
    DateTimeZone dateTimeZone = DateTimeZone.UTC;
    AnomalyFunctionDTO anomalyFunction = new AnomalyFunctionDTO();
    anomalyFunction.setFrequency(new TimeGranularity(15, TimeUnit.MINUTES));
    DateTimeFormatter dateTimeFormatter = DetectionJobSchedulerUtils.getDateTimeFormatterForDataset(datasetConfig, dateTimeZone);
    String currentDateTimeString = "201702140336";
    String currentDateTimeStringRounded = "201702140330";
    DateTime currentDateTime = minuteDateTimeFormatter.parseDateTime(currentDateTimeString);
    DateTime currentDateTimeRounded = dateTimeFormatter.parseDateTime(currentDateTimeStringRounded);
    DetectionStatusDTO lastEntryForFunction = null;
    // null last entry
    Map<String, Long> newEntries = DetectionJobSchedulerUtils.getNewEntries(currentDateTime, lastEntryForFunction, anomalyFunction, datasetConfig, dateTimeZone);
    Assert.assertEquals(newEntries.size(), 1);
    Assert.assertEquals(newEntries.get(currentDateTimeStringRounded), new Long(currentDateTimeRounded.getMillis()));
    // last entry same as current time
    lastEntryForFunction = new DetectionStatusDTO();
    lastEntryForFunction.setDateToCheckInSDF(currentDateTimeStringRounded);
    lastEntryForFunction.setDateToCheckInMS(currentDateTimeRounded.getMillis());
    newEntries = DetectionJobSchedulerUtils.getNewEntries(currentDateTime, lastEntryForFunction, anomalyFunction, datasetConfig, dateTimeZone);
    Assert.assertEquals(newEntries.size(), 0);
    // last entry 15 MINUTES before current time
    String lastEntryDateTimeString = "201702140315";
    DateTime lastEntryDateTime = dateTimeFormatter.parseDateTime(lastEntryDateTimeString);
    lastEntryForFunction = new DetectionStatusDTO();
    lastEntryForFunction.setDateToCheckInSDF(lastEntryDateTimeString);
    lastEntryForFunction.setDateToCheckInMS(lastEntryDateTime.getMillis());
    newEntries = DetectionJobSchedulerUtils.getNewEntries(currentDateTime, lastEntryForFunction, anomalyFunction, datasetConfig, dateTimeZone);
    Assert.assertEquals(newEntries.size(), 1);
    Assert.assertEquals(newEntries.get(currentDateTimeStringRounded), new Long(currentDateTimeRounded.getMillis()));
    // last entry 45 MINUTES  before current time
    lastEntryDateTimeString = "201702140245";
    lastEntryDateTime = dateTimeFormatter.parseDateTime(lastEntryDateTimeString);
    lastEntryForFunction = new DetectionStatusDTO();
    lastEntryForFunction.setDateToCheckInSDF(lastEntryDateTimeString);
    lastEntryForFunction.setDateToCheckInMS(lastEntryDateTime.getMillis());
    newEntries = DetectionJobSchedulerUtils.getNewEntries(currentDateTime, lastEntryForFunction, anomalyFunction, datasetConfig, dateTimeZone);
    Assert.assertEquals(newEntries.size(), 3);
    Assert.assertNotNull(newEntries.get("201702140300"));
    Assert.assertNotNull(newEntries.get("201702140315"));
    Assert.assertNotNull(newEntries.get("201702140330"));
    Assert.assertEquals(newEntries.get(currentDateTimeStringRounded), new Long(currentDateTimeRounded.getMillis()));
}
Also used : DatasetConfigDTO(com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO) TimeGranularity(com.linkedin.thirdeye.api.TimeGranularity) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

DetectionStatusDTO (com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO)12 DateTime (org.joda.time.DateTime)7 AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)5 Test (org.testng.annotations.Test)5 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)4 DateTimeZone (org.joda.time.DateTimeZone)4 ArrayList (java.util.ArrayList)3 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 DetectionStatusBean (com.linkedin.thirdeye.datalayer.pojo.DetectionStatusBean)2 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)2 ParseException (java.text.ParseException)2 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)1 ExecutionException (java.util.concurrent.ExecutionException)1 CronExpression (org.quartz.CronExpression)1 SchedulerException (org.quartz.SchedulerException)1