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