Search in sources :

Example 21 with EmailConfigurationDTO

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

the class AlertJobScheduler method runAdHoc.

public void runAdHoc(Long id, DateTime windowStartTime, DateTime windowEndTime) {
    EmailConfigurationDTO alertConfig = emailConfigurationDAO.findById(id);
    if (alertConfig == null) {
        throw new IllegalArgumentException("No alert config with id " + id);
    }
    String triggerKey = String.format("alert_adhoc_trigger_%d", id);
    Trigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).startNow().build();
    String jobKey = "adhoc_" + getJobKey(id);
    JobDetail job = JobBuilder.newJob(AlertJobRunner.class).withIdentity(jobKey).build();
    AlertJobContext alertJobContext = new AlertJobContext();
    alertJobContext.setJobDAO(anomalyJobDAO);
    alertJobContext.setTaskDAO(anomalyTaskDAO);
    alertJobContext.setEmailConfigurationDAO(emailConfigurationDAO);
    alertJobContext.setAlertConfigId(id);
    alertJobContext.setJobName(jobKey);
    job.getJobDataMap().put(AlertJobRunner.ALERT_JOB_CONTEXT, alertJobContext);
    job.getJobDataMap().put(AlertJobRunner.ALERT_JOB_MONITORING_WINDOW_START_TIME, windowStartTime);
    job.getJobDataMap().put(AlertJobRunner.ALERT_JOB_MONITORING_WINDOW_END_TIME, windowEndTime);
    try {
        quartzScheduler.scheduleJob(job, trigger);
    } catch (SchedulerException e) {
        LOG.error("Exception while scheduling job", e);
    }
    LOG.info("Started {}: {}", jobKey, alertConfig);
}
Also used : JobDetail(org.quartz.JobDetail) Trigger(org.quartz.Trigger) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)

Example 22 with EmailConfigurationDTO

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

the class AlertJobScheduler method startJob.

public void startJob(Long id) throws SchedulerException {
    EmailConfigurationDTO alertConfig = emailConfigurationDAO.findById(id);
    if (alertConfig == null) {
        throw new IllegalArgumentException("No alert config with id " + id);
    }
    if (!alertConfig.isActive()) {
        throw new IllegalStateException("Alert config with id " + id + " is not active");
    }
    String jobKey = getJobKey(alertConfig.getId());
    startJob(alertConfig, jobKey);
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)

Example 23 with EmailConfigurationDTO

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

the class AlertJobResource method toggleActive.

private void toggleActive(Long id, boolean state) {
    EmailConfigurationDTO alertConfig = emailConfigurationDAO.findById(id);
    if (alertConfig == null) {
        throw new NullArgumentException("Alert config not found");
    }
    alertConfig.setActive(state);
    emailConfigurationDAO.update(alertConfig);
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) NullArgumentException(org.apache.commons.lang.NullArgumentException)

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