Search in sources :

Example 1 with EmailConfig

use of com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean.EmailConfig 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)

Aggregations

AlertConfigDTO (com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)1 EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)1 EmailConfig (com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean.EmailConfig)1 HashSet (java.util.HashSet)1