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