Search in sources :

Example 6 with EmailConfigurationDTO

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

the class EmailConfigurationManagerImpl method findByCollectionMetric.

@Override
public List<EmailConfigurationDTO> findByCollectionMetric(String collection, String metric) {
    Predicate predicate = Predicate.AND(Predicate.EQ("collection", collection), Predicate.EQ("metric", metric));
    List<EmailConfigurationBean> list = genericPojoDao.get(predicate, EmailConfigurationBean.class);
    List<EmailConfigurationDTO> result = new ArrayList<>();
    for (EmailConfigurationBean bean : list) {
        EmailConfigurationDTO dto = convertEmailConfigurationBean2DTO(bean);
        result.add(dto);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) EmailConfigurationBean(com.linkedin.thirdeye.datalayer.pojo.EmailConfigurationBean) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 7 with EmailConfigurationDTO

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

the class RunAdhocDatabaseQueriesTool method updateEmailConfigs.

private void updateEmailConfigs() {
    List<EmailConfigurationDTO> emailConfigs = emailConfigurationDAO.findAll();
    for (EmailConfigurationDTO emailConfig : emailConfigs) {
        emailConfig.setActive(false);
        emailConfigurationDAO.update(emailConfig);
    }
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)

Example 8 with EmailConfigurationDTO

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

the class RunAdhocDatabaseQueriesTool method playWithAlertCOnfigs.

private void playWithAlertCOnfigs() {
    List<EmailConfigurationDTO> emailConfigs = emailConfigurationDAO.findAll();
    Multimap<String, EmailConfigurationDTO> datasetToEmailConfig = ArrayListMultimap.create();
    for (EmailConfigurationDTO emailConfig : emailConfigs) {
        if (emailConfig.isActive() && !emailConfig.getFunctionIds().isEmpty()) {
            datasetToEmailConfig.put(emailConfig.getCollection(), emailConfig);
        }
    }
    for (String dataset : datasetToEmailConfig.keySet()) {
        List<EmailConfigurationDTO> emailConfigsList = Lists.newArrayList(datasetToEmailConfig.get(dataset));
        String name = "Beta " + dataset + " Alert Config";
        String cron = emailConfigsList.get(0).getCron();
        boolean active = true;
        long watermark = 0L;
        Set<Long> functionIds = new HashSet<>();
        for (EmailConfigurationDTO config : emailConfigsList) {
            functionIds.addAll(config.getFunctionIds());
        }
        EmailConfig emailConfig = new EmailConfig();
        emailConfig.setAnomalyWatermark(watermark);
        emailConfig.setFunctionIds(Lists.newArrayList(functionIds));
        String recipients = "thirdeyeproductteam@linkedin.com";
        String fromAddress = "thirdeye-dev@linkedin.com";
        AlertConfigDTO alertConfig = new AlertConfigDTO();
        alertConfig.setName(name);
        alertConfig.setCronExpression(cron);
        alertConfig.setActive(active);
        alertConfig.setEmailConfig(emailConfig);
        alertConfig.setRecipients(recipients);
        alertConfig.setFromAddress(fromAddress);
        System.out.println(alertConfig);
        alertConfigDAO.save(alertConfig);
    }
}
Also used : EmailConfig(com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean.EmailConfig) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO) HashSet(java.util.HashSet)

Example 9 with EmailConfigurationDTO

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

the class TestEmailConfigurationManager method testDelete.

@Test(dependsOnMethods = { "testFindByFunctionId" })
public void testDelete() {
    emailConfigurationDAO.deleteById(emailConfigId);
    EmailConfigurationDTO emailConfiguration = emailConfigurationDAO.findById(emailConfigId);
    AnomalyFunctionDTO anomalyFunctionSpec = anomalyFunctionDAO.findById(functionId);
    // email configuration should be deleted and anomaly function should not.
    assertNull(emailConfiguration);
    assertNotNull(anomalyFunctionSpec);
    // now cleanup the anomaly function
    anomalyFunctionDAO.deleteById(anomalyFunctionSpec.getId());
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) Test(org.testng.annotations.Test)

Example 10 with EmailConfigurationDTO

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

the class EmailConfigurationManagerImpl method convertEmailConfigurationBean2DTO.

private EmailConfigurationDTO convertEmailConfigurationBean2DTO(EmailConfigurationBean emailConfigurationBean) {
    EmailConfigurationDTO emailConfigurationDTO = convertBean2DTO(emailConfigurationBean, EmailConfigurationDTO.class);
    List<Long> functionIds = emailConfigurationBean.getFunctionIds();
    if (functionIds != null && !functionIds.isEmpty()) {
        List<AnomalyFunctionBean> list = genericPojoDao.get(functionIds, AnomalyFunctionBean.class);
        List<AnomalyFunctionDTO> functions = new ArrayList<>();
        for (AnomalyFunctionBean bean : list) {
            AnomalyFunctionDTO dto = convertBean2DTO(bean, AnomalyFunctionDTO.class);
            functions.add(dto);
        }
        emailConfigurationDTO.setFunctions(functions);
    }
    return emailConfigurationDTO;
}
Also used : AnomalyFunctionBean(com.linkedin.thirdeye.datalayer.pojo.AnomalyFunctionBean) ArrayList(java.util.ArrayList) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Aggregations

EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)23 ArrayList (java.util.ArrayList)8 AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)7 EmailConfigurationBean (com.linkedin.thirdeye.datalayer.pojo.EmailConfigurationBean)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)3 Test (org.testng.annotations.Test)3 AlertConfigDTO (com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)2 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)2 CronTrigger (org.quartz.CronTrigger)2 SchedulerException (org.quartz.SchedulerException)2 Trigger (org.quartz.Trigger)2 AlertTaskInfo (com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo)1 EmailConfigurationManager (com.linkedin.thirdeye.datalayer.bao.EmailConfigurationManager)1 DashboardConfigDTO (com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)1 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)1 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)1 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)1 OverrideConfigDTO (com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO)1 RawAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO)1