Search in sources :

Example 6 with OverrideConfigDTO

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

the class AbstractManagerTestBase method getTestOverrideConfigForTimeSeries.

protected OverrideConfigDTO getTestOverrideConfigForTimeSeries(DateTime now) {
    OverrideConfigDTO overrideConfigDTO = new OverrideConfigDTO();
    overrideConfigDTO.setStartTime(now.minusHours(8).getMillis());
    overrideConfigDTO.setEndTime(now.plusHours(8).getMillis());
    overrideConfigDTO.setTargetEntity(OverrideConfigHelper.ENTITY_TIME_SERIES);
    overrideConfigDTO.setActive(true);
    Map<String, String> overrideProperties = new HashMap<>();
    overrideProperties.put(ScalingFactor.SCALING_FACTOR, "1.2");
    overrideConfigDTO.setOverrideProperties(overrideProperties);
    Map<String, List<String>> overrideTarget = new HashMap<>();
    overrideTarget.put(OverrideConfigHelper.TARGET_COLLECTION, Arrays.asList("collection1", "collection2"));
    overrideTarget.put(OverrideConfigHelper.EXCLUDED_COLLECTION, Arrays.asList("collection3"));
    overrideConfigDTO.setTargetLevel(overrideTarget);
    return overrideConfigDTO;
}
Also used : OverrideConfigDTO(com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO) HashMap(java.util.HashMap) List(java.util.List)

Example 7 with OverrideConfigDTO

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

the class RunAdhocDatabaseQueriesTool method updateOverrideConfig.

private void updateOverrideConfig(long id, OverrideConfigDTO overrideConfigDTO) {
    OverrideConfigDTO overrideConfigToUpdated = overrideConfigDAO.findById(id);
    if (overrideConfigToUpdated == null) {
        LOG.warn("Failed to update config {}", id);
    } else {
        overrideConfigToUpdated.setStartTime(overrideConfigDTO.getStartTime());
        overrideConfigToUpdated.setEndTime(overrideConfigDTO.getEndTime());
        overrideConfigToUpdated.setTargetLevel(overrideConfigDTO.getTargetLevel());
        overrideConfigToUpdated.setTargetEntity(overrideConfigDTO.getTargetEntity());
        overrideConfigToUpdated.setOverrideProperties(overrideConfigDTO.getOverrideProperties());
        overrideConfigToUpdated.setActive(overrideConfigDTO.getActive());
        overrideConfigDAO.update(overrideConfigToUpdated);
        LOG.info("Updated config {}" + id);
    }
}
Also used : OverrideConfigDTO(com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO)

Example 8 with OverrideConfigDTO

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

the class TestOverrideConfigManager method testUpdate.

@Test(dependsOnMethods = { "testFind" })
public void testUpdate() {
    // Test update of override property
    OverrideConfigDTO overrideConfigDTO = overrideConfigDAO.findById(overrideConfigId1);
    Assert.assertNotNull(overrideConfigDTO);
    Assert.assertNotNull(overrideConfigDTO.getOverrideProperties());
    Assert.assertNotNull(overrideConfigDTO.getOverrideProperties().get(ScalingFactor.SCALING_FACTOR));
    Assert.assertEquals(overrideConfigDTO.getOverrideProperties().get(ScalingFactor.SCALING_FACTOR), "1.2");
    Map<String, String> newOverrideProperties = new HashMap<>();
    newOverrideProperties.put(ScalingFactor.SCALING_FACTOR, "0.8");
    overrideConfigDTO.setOverrideProperties(newOverrideProperties);
    overrideConfigDAO.update(overrideConfigDTO);
    overrideConfigDTO = overrideConfigDAO.findById(overrideConfigId1);
    Assert.assertNotNull(overrideConfigDTO);
    Assert.assertNotNull(overrideConfigDTO.getOverrideProperties());
    Assert.assertNotNull(overrideConfigDTO.getOverrideProperties().get(ScalingFactor.SCALING_FACTOR));
    Assert.assertEquals(overrideConfigDTO.getOverrideProperties().get(ScalingFactor.SCALING_FACTOR), "0.8");
    // Test update of target level
    overrideConfigDTO = overrideConfigDAO.findById(overrideConfigId1);
    Assert.assertNotNull(overrideConfigDTO);
    Assert.assertNotNull(overrideConfigDTO.getTargetLevel());
    List<String> targetLevel = overrideConfigDTO.getTargetLevel().get(OverrideConfigHelper.TARGET_COLLECTION);
    Assert.assertNotNull(targetLevel);
    Assert.assertEquals(targetLevel, Arrays.asList("collection1", "collection2"));
    List<String> newTargetLevel = Arrays.asList("collection1", "collection4");
    overrideConfigDTO.getTargetLevel().put(OverrideConfigHelper.TARGET_COLLECTION, newTargetLevel);
    overrideConfigDAO.update(overrideConfigDTO);
    overrideConfigDTO = overrideConfigDAO.findById(overrideConfigId1);
    Assert.assertNotNull(overrideConfigDTO);
    Assert.assertNotNull(overrideConfigDTO.getTargetLevel());
    targetLevel = overrideConfigDTO.getTargetLevel().get(OverrideConfigHelper.TARGET_COLLECTION);
    Assert.assertNotNull(targetLevel);
    Assert.assertEquals(targetLevel, Arrays.asList("collection1", "collection4"));
}
Also used : OverrideConfigDTO(com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 9 with OverrideConfigDTO

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

the class TestOverrideConfigManager method testCreate.

@Test
public void testCreate() {
    OverrideConfigDTO overrideConfigDTO1 = getTestOverrideConfigForTimeSeries(now);
    overrideConfigId1 = overrideConfigDAO.save(overrideConfigDTO1);
    Assert.assertNotNull(overrideConfigId1);
    Assert.assertNotNull(overrideConfigDAO.findById(overrideConfigId1));
}
Also used : OverrideConfigDTO(com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO) Test(org.testng.annotations.Test)

Example 10 with OverrideConfigDTO

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

the class TestOverrideConfigManager method testDelete.

@Test(dependsOnMethods = { "testUpdate" })
public void testDelete() {
    overrideConfigDAO.deleteById(overrideConfigId1);
    OverrideConfigDTO overrideConfigDTO = overrideConfigDAO.findById(overrideConfigId1);
    Assert.assertNull(overrideConfigDTO);
}
Also used : OverrideConfigDTO(com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO) Test(org.testng.annotations.Test)

Aggregations

OverrideConfigDTO (com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO)12 HashMap (java.util.HashMap)5 List (java.util.List)4 Test (org.testng.annotations.Test)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 POST (javax.ws.rs.POST)3 OverrideConfigManager (com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager)2 Path (javax.ws.rs.Path)2 AlertConfigDTO (com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)1 AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)1 DashboardConfigDTO (com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)1 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)1 EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)1 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)1 OverrideConfigBean (com.linkedin.thirdeye.datalayer.pojo.OverrideConfigBean)1 ScalingFactor (com.linkedin.thirdeye.detector.metric.transfer.ScalingFactor)1 HashSet (java.util.HashSet)1 WebApplicationException (javax.ws.rs.WebApplicationException)1