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);
}
}
}
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);
}
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);
}
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;
}
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()));
}
Aggregations