use of com.linkedin.thirdeye.datalayer.dto.TaskDTO 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;
}
use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.
the class DetectionJobRunner method createTasks.
private List<Long> createTasks(DetectionJobContext detectionJobContext, List<DateTime> monitoringWindowStartTimes, List<DateTime> monitoringWindowEndTimes) {
List<Long> taskIds = new ArrayList<>();
try {
List<DetectionTaskInfo> tasks = taskGenerator.createDetectionTasks(detectionJobContext, monitoringWindowStartTimes, monitoringWindowEndTimes);
for (DetectionTaskInfo taskInfo : tasks) {
String taskInfoJson = null;
try {
taskInfoJson = OBJECT_MAPPER.writeValueAsString(taskInfo);
} catch (JsonProcessingException e) {
LOG.error("Exception when converting DetectionTaskInfo {} to jsonString", taskInfo, e);
}
TaskDTO taskSpec = new TaskDTO();
taskSpec.setTaskType(TaskType.ANOMALY_DETECTION);
taskSpec.setJobName(detectionJobContext.getJobName());
taskSpec.setStatus(TaskStatus.WAITING);
taskSpec.setStartTime(System.currentTimeMillis());
taskSpec.setTaskInfo(taskInfoJson);
taskSpec.setJobId(detectionJobContext.getJobExecutionId());
long taskId = DAO_REGISTRY.getTaskDAO().save(taskSpec);
taskIds.add(taskId);
LOG.info("Created anomalyTask {} with taskId {}", taskSpec, taskId);
}
} catch (Exception e) {
LOG.error("Exception in creating detection tasks", e);
}
return taskIds;
}
use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.
the class DataCompletenessJobRunner method createTasks.
public List<Long> createTasks() {
List<Long> taskIds = new ArrayList<>();
try {
LOG.info("Creating data completeness checker tasks");
List<DataCompletenessTaskInfo> dataCompletenessTasks = createDataCompletenessTasks(dataCompletenessJobContext);
LOG.info("DataCompleteness tasks {}", dataCompletenessTasks);
for (DataCompletenessTaskInfo taskInfo : dataCompletenessTasks) {
String taskInfoJson = null;
try {
taskInfoJson = OBJECT_MAPPER.writeValueAsString(taskInfo);
} catch (JsonProcessingException e) {
LOG.error("Exception when converting DataCompletenessTaskInfo {} to jsonString", taskInfo, e);
}
TaskDTO taskSpec = new TaskDTO();
taskSpec.setTaskType(TaskType.DATA_COMPLETENESS);
taskSpec.setJobName(dataCompletenessJobContext.getJobName());
taskSpec.setStatus(TaskStatus.WAITING);
taskSpec.setStartTime(System.currentTimeMillis());
taskSpec.setTaskInfo(taskInfoJson);
taskSpec.setJobId(dataCompletenessJobContext.getJobExecutionId());
long taskId = DAO_REGISTRY.getTaskDAO().save(taskSpec);
taskIds.add(taskId);
LOG.info("Created dataCompleteness task {} with taskId {}", taskSpec, taskId);
}
} catch (Exception e) {
LOG.error("Exception in creating data completeness tasks", e);
}
return taskIds;
}
use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.
the class TaskManagerImpl method updateStatusAndWorkerId.
@Override
public boolean updateStatusAndWorkerId(Long workerId, Long id, Set<TaskStatus> permittedOldStatus, TaskStatus newStatus, int expectedVersion) {
TaskDTO task = findById(id);
if (permittedOldStatus.contains(task.getStatus())) {
task.setStatus(newStatus);
task.setWorkerId(workerId);
//increment the version
task.setVersion(expectedVersion + 1);
Predicate predicate = Predicate.AND(Predicate.EQ("id", id), Predicate.EQ("version", expectedVersion));
int update = update(task, predicate);
return update == 1;
} else {
return false;
}
}
use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.
the class TaskManagerImpl method findByJobIdStatusNotIn.
@Override
public List<TaskDTO> findByJobIdStatusNotIn(Long jobId, TaskStatus status) {
Predicate jobIdPredicate = Predicate.EQ("jobId", jobId);
Predicate statusPredicate = Predicate.NEQ("status", status.toString());
List<TaskBean> list = genericPojoDao.get(Predicate.AND(statusPredicate, jobIdPredicate), TaskBean.class);
List<TaskDTO> result = new ArrayList<>();
for (TaskBean bean : list) {
result.add((TaskDTO) MODEL_MAPPER.map(bean, TaskDTO.class));
}
return result;
}
Aggregations