Search in sources :

Example 1 with DetectionStatusBean

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

the class DetectionStatusManagerImpl method findLatestEntryForFunctionId.

@Override
public DetectionStatusDTO findLatestEntryForFunctionId(long functionId) {
    Predicate predicate = Predicate.EQ("functionId", functionId);
    List<DetectionStatusBean> list = genericPojoDao.get(predicate, DetectionStatusBean.class);
    DetectionStatusDTO result = null;
    if (CollectionUtils.isNotEmpty(list)) {
        Collections.sort(list);
        result = (DetectionStatusDTO) MODEL_MAPPER.map(list.get(list.size() - 1), DetectionStatusDTO.class);
    }
    return result;
}
Also used : DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO) DetectionStatusBean(com.linkedin.thirdeye.datalayer.pojo.DetectionStatusBean) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 2 with DetectionStatusBean

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

the class DetectionStatusManagerImpl method findAllInTimeRangeForFunctionAndDetectionRun.

@Override
public List<DetectionStatusDTO> findAllInTimeRangeForFunctionAndDetectionRun(long startTime, long endTime, long functionId, boolean detectionRun) {
    Predicate predicate = Predicate.AND(Predicate.EQ("functionId", functionId), Predicate.LE("dateToCheckInMS", endTime), Predicate.GE("dateToCheckInMS", startTime), Predicate.EQ("detectionRun", detectionRun));
    List<DetectionStatusBean> list = genericPojoDao.get(predicate, DetectionStatusBean.class);
    List<DetectionStatusDTO> results = new ArrayList<>();
    for (DetectionStatusBean bean : list) {
        results.add((DetectionStatusDTO) MODEL_MAPPER.map(bean, DetectionStatusDTO.class));
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) DetectionStatusDTO(com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO) DetectionStatusBean(com.linkedin.thirdeye.datalayer.pojo.DetectionStatusBean) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 3 with DetectionStatusBean

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

the class DetectionStatusManagerImpl method deleteRecordsOlderThanDays.

@Override
@Transactional
public int deleteRecordsOlderThanDays(int days) {
    DateTime expireDate = new DateTime().minusDays(days);
    Timestamp expireTimestamp = new Timestamp(expireDate.getMillis());
    Predicate timestampPredicate = Predicate.LT("createTime", expireTimestamp);
    List<DetectionStatusBean> list = genericPojoDao.get(timestampPredicate, DetectionStatusBean.class);
    for (DetectionStatusBean bean : list) {
        deleteById(bean.getId());
    }
    return list.size();
}
Also used : Timestamp(java.sql.Timestamp) DateTime(org.joda.time.DateTime) DetectionStatusBean(com.linkedin.thirdeye.datalayer.pojo.DetectionStatusBean) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate) Transactional(com.google.inject.persist.Transactional)

Aggregations

DetectionStatusBean (com.linkedin.thirdeye.datalayer.pojo.DetectionStatusBean)3 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)3 DetectionStatusDTO (com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO)2 Transactional (com.google.inject.persist.Transactional)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1