Search in sources :

Example 1 with JobBean

use of com.linkedin.thirdeye.datalayer.pojo.JobBean in project pinot by linkedin.

the class JobManagerImpl method deleteRecordsOlderThanDaysWithStatus.

@Override
@Transactional
public int deleteRecordsOlderThanDaysWithStatus(int days, JobStatus status) {
    DateTime expireDate = new DateTime().minusDays(days);
    Timestamp expireTimestamp = new Timestamp(expireDate.getMillis());
    Predicate statusPredicate = Predicate.EQ("status", status.toString());
    Predicate timestampPredicate = Predicate.LT("updateTime", expireTimestamp);
    List<JobBean> list = genericPojoDao.get(Predicate.AND(statusPredicate, timestampPredicate), JobBean.class);
    for (JobBean jobBean : list) {
        deleteById(jobBean.getId());
    }
    return list.size();
}
Also used : JobBean(com.linkedin.thirdeye.datalayer.pojo.JobBean) Timestamp(java.sql.Timestamp) DateTime(org.joda.time.DateTime) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate) Transactional(com.google.inject.persist.Transactional)

Example 2 with JobBean

use of com.linkedin.thirdeye.datalayer.pojo.JobBean in project pinot by linkedin.

the class JobManagerImpl method findLatestBackfillScheduledJobByFunctionId.

@Override
public JobDTO findLatestBackfillScheduledJobByFunctionId(long functionId, long backfillWindowStart, long backfillWindowEnd) {
    String parameterizedSQL = "where name like \"" + DetectionTaskRunner.BACKFILL_PREFIX + "%" + functionId + "\" ";
    HashMap<String, Object> parameterMap = new HashMap<>();
    List<JobBean> list = genericPojoDao.executeParameterizedSQL(parameterizedSQL, parameterMap, JobBean.class);
    if (CollectionUtils.isNotEmpty(list)) {
        // Sort by start window time in descending order
        Collections.sort(list, new Comparator<JobBean>() {

            @Override
            public int compare(JobBean j1, JobBean j2) {
                return (int) ((j2.getWindowStartTime() / 1000) - (j1.getWindowStartTime() / 1000));
            }
        });
        // Find the latest job whose start time is located between backfill window
        for (JobBean job : list) {
            long jobStartTime = job.getWindowStartTime();
            if (backfillWindowStart <= jobStartTime && jobStartTime <= backfillWindowEnd) {
                return convertBean2DTO(job, JobDTO.class);
            }
        }
    }
    return null;
}
Also used : HashMap(java.util.HashMap) JobBean(com.linkedin.thirdeye.datalayer.pojo.JobBean)

Example 3 with JobBean

use of com.linkedin.thirdeye.datalayer.pojo.JobBean in project pinot by linkedin.

the class JobManagerImpl method findLatestScheduledJobByName.

@Override
public JobDTO findLatestScheduledJobByName(String jobName) {
    Predicate namePredicate = Predicate.EQ("name", jobName);
    Predicate statusPredicate = Predicate.EQ("status", "SCHEDULED");
    List<JobBean> list = genericPojoDao.get(Predicate.AND(statusPredicate, namePredicate), JobBean.class);
    if (CollectionUtils.isNotEmpty(list)) {
        JobDTO dto = convertBean2DTO(list.get(0), JobDTO.class);
        return dto;
    }
    return null;
}
Also used : JobDTO(com.linkedin.thirdeye.datalayer.dto.JobDTO) JobBean(com.linkedin.thirdeye.datalayer.pojo.JobBean) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 4 with JobBean

use of com.linkedin.thirdeye.datalayer.pojo.JobBean in project pinot by linkedin.

the class JobManagerImpl method findNRecentJobs.

@Override
public List<JobDTO> findNRecentJobs(int n) {
    String parameterizedSQL = "order by scheduleStartTime desc limit " + n;
    HashMap<String, Object> parameterMap = new HashMap<>();
    List<JobBean> list = genericPojoDao.executeParameterizedSQL(parameterizedSQL, parameterMap, JobBean.class);
    List<JobDTO> ret = new ArrayList<>();
    for (JobBean bean : list) {
        JobDTO dto = convertBean2DTO(bean, JobDTO.class);
        ret.add(dto);
    }
    return ret;
}
Also used : JobDTO(com.linkedin.thirdeye.datalayer.dto.JobDTO) HashMap(java.util.HashMap) JobBean(com.linkedin.thirdeye.datalayer.pojo.JobBean) ArrayList(java.util.ArrayList)

Aggregations

JobBean (com.linkedin.thirdeye.datalayer.pojo.JobBean)4 JobDTO (com.linkedin.thirdeye.datalayer.dto.JobDTO)2 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)2 HashMap (java.util.HashMap)2 Transactional (com.google.inject.persist.Transactional)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1