Search in sources :

Example 1 with AlertTaskInfo

use of com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo in project pinot by linkedin.

the class AlertTaskRunnerV2 method execute.

@Override
public List<TaskResult> execute(TaskInfo taskInfo, TaskContext taskContext) throws Exception {
    List<TaskResult> taskResult = new ArrayList<>();
    AlertTaskInfo alertTaskInfo = (AlertTaskInfo) taskInfo;
    alertConfig = alertTaskInfo.getAlertConfigDTO();
    thirdeyeConfig = taskContext.getThirdEyeAnomalyConfiguration();
    alertFilterFactory = new AlertFilterFactory(thirdeyeConfig.getAlertFilterConfigPath());
    try {
        LOG.info("Begin executing task {}", taskInfo);
        runTask();
    } catch (Exception t) {
        LOG.error("Task failed with exception:", t);
        sendFailureEmail(t);
        // Let task driver mark this task failed
        throw t;
    }
    return taskResult;
}
Also used : AlertFilterFactory(com.linkedin.thirdeye.detector.email.filter.AlertFilterFactory) AlertTaskInfo(com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo) ArrayList(java.util.ArrayList) TaskResult(com.linkedin.thirdeye.anomaly.task.TaskResult) JobExecutionException(org.quartz.JobExecutionException) EmailException(org.apache.commons.mail.EmailException)

Example 2 with AlertTaskInfo

use of com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo in project pinot by linkedin.

the class TaskGenerator method createAlertTasksV2.

public List<AlertTaskInfo> createAlertTasksV2(AlertJobContext alertJobContext, DateTime monitoringWindowStartTime, DateTime monitoringWindowEndTime) throws Exception {
    List<AlertTaskInfo> tasks = new ArrayList<>();
    AlertConfigDTO alertConfig = alertJobContext.getAlertConfigDTO();
    long jobExecutionId = alertJobContext.getJobExecutionId();
    AlertTaskInfo taskInfo = new AlertTaskInfo(jobExecutionId, monitoringWindowStartTime, monitoringWindowEndTime, null, alertConfig);
    tasks.add(taskInfo);
    return tasks;
}
Also used : AlertTaskInfo(com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo) ArrayList(java.util.ArrayList) AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)

Example 3 with AlertTaskInfo

use of com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo in project pinot by linkedin.

the class TaskGenerator method createAlertTasks.

public List<AlertTaskInfo> createAlertTasks(AlertJobContext alertJobContext, DateTime monitoringWindowStartTime, DateTime monitoringWindowEndTime) throws Exception {
    List<AlertTaskInfo> tasks = new ArrayList<>();
    EmailConfigurationDTO alertConfig = alertJobContext.getAlertConfig();
    long jobExecutionId = alertJobContext.getJobExecutionId();
    AlertTaskInfo taskInfo = new AlertTaskInfo(jobExecutionId, monitoringWindowStartTime, monitoringWindowEndTime, alertConfig, null);
    tasks.add(taskInfo);
    return tasks;
}
Also used : AlertTaskInfo(com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo) ArrayList(java.util.ArrayList) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)

Example 4 with AlertTaskInfo

use of com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo in project pinot by linkedin.

the class AlertJobRunnerV2 method createTasks.

private List<Long> createTasks(DateTime monitoringWindowStartTime, DateTime monitoringWindowEndTime) {
    List<Long> taskIds = new ArrayList<>();
    try {
        List<AlertTaskInfo> tasks = taskGenerator.createAlertTasksV2(alertJobContext, monitoringWindowStartTime, monitoringWindowEndTime);
        for (AlertTaskInfo taskInfo : tasks) {
            String taskInfoJson = null;
            try {
                taskInfoJson = OBJECT_MAPPER.writeValueAsString(taskInfo);
            } catch (JsonProcessingException e) {
                LOG.error("Exception when converting AlertTaskInfo {} to jsonString", taskInfo, e);
            }
            TaskDTO taskSpec = new TaskDTO();
            taskSpec.setTaskType(TaskConstants.TaskType.ALERT2);
            taskSpec.setJobName(alertJobContext.getJobName());
            taskSpec.setStatus(TaskConstants.TaskStatus.WAITING);
            taskSpec.setStartTime(System.currentTimeMillis());
            taskSpec.setTaskInfo(taskInfoJson);
            taskSpec.setJobId(alertJobContext.getJobExecutionId());
            long taskId = taskDAO.save(taskSpec);
            taskIds.add(taskId);
            LOG.info("Created alert task {} with taskId {}", taskSpec, taskId);
        }
    } catch (Exception e) {
        LOG.error("Exception in creating alert tasks", e);
    }
    return taskIds;
}
Also used : AlertTaskInfo(com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo) ArrayList(java.util.ArrayList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JobExecutionException(org.quartz.JobExecutionException)

Aggregations

AlertTaskInfo (com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo)4 ArrayList (java.util.ArrayList)4 JobExecutionException (org.quartz.JobExecutionException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 TaskResult (com.linkedin.thirdeye.anomaly.task.TaskResult)1 AlertConfigDTO (com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)1 EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)1 TaskDTO (com.linkedin.thirdeye.datalayer.dto.TaskDTO)1 AlertFilterFactory (com.linkedin.thirdeye.detector.email.filter.AlertFilterFactory)1 EmailException (org.apache.commons.mail.EmailException)1