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