Search in sources :

Example 1 with MergedAnomalyResultBean

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

the class MergedAnomalyResultManagerImpl method findLatestConflictByFunctionIdDimensions.

@Override
public MergedAnomalyResultDTO findLatestConflictByFunctionIdDimensions(Long functionId, String dimensions, long conflictWindowStart, long conflictWindowEnd) {
    Map<String, Object> filterParams = new HashMap<>();
    filterParams.put("functionId", functionId);
    filterParams.put("dimensions", dimensions);
    filterParams.put("startTime", conflictWindowStart);
    filterParams.put("endTime", conflictWindowEnd);
    List<MergedAnomalyResultBean> list = genericPojoDao.executeParameterizedSQL(FIND_LATEST_CONFLICT_BY_FUNCTION_AND_DIMENSIONS, filterParams, MergedAnomalyResultBean.class);
    if (CollectionUtils.isNotEmpty(list)) {
        MergedAnomalyResultBean mostRecentConflictMergedAnomalyResultBean = list.get(0);
        return convertMergedAnomalyBean2DTO(mostRecentConflictMergedAnomalyResultBean, true);
    }
    return null;
}
Also used : HashMap(java.util.HashMap) MergedAnomalyResultBean(com.linkedin.thirdeye.datalayer.pojo.MergedAnomalyResultBean)

Example 2 with MergedAnomalyResultBean

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

the class MergedAnomalyResultManagerImpl method convertMergeAnomalyDTO2Bean.

protected MergedAnomalyResultBean convertMergeAnomalyDTO2Bean(MergedAnomalyResultDTO entity) {
    MergedAnomalyResultBean bean = convertDTO2Bean(entity, MergedAnomalyResultBean.class);
    if (entity.getFeedback() != null && entity.getFeedback().getId() != null) {
        bean.setAnomalyFeedbackId(entity.getFeedback().getId());
    }
    if (entity.getFunction() != null) {
        bean.setFunctionId(entity.getFunction().getId());
    }
    if (entity.getAnomalyResults() != null && !entity.getAnomalyResults().isEmpty()) {
        List<Long> rawAnomalyIds = new ArrayList<>();
        for (RawAnomalyResultDTO rawAnomalyDTO : entity.getAnomalyResults()) {
            rawAnomalyIds.add(rawAnomalyDTO.getId());
        }
        bean.setRawAnomalyIdList(rawAnomalyIds);
    }
    return bean;
}
Also used : RawAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO) MergedAnomalyResultBean(com.linkedin.thirdeye.datalayer.pojo.MergedAnomalyResultBean) ArrayList(java.util.ArrayList)

Example 3 with MergedAnomalyResultBean

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

the class MergedAnomalyResultManagerImpl method save.

public Long save(MergedAnomalyResultDTO mergedAnomalyResultDTO) {
    if (mergedAnomalyResultDTO.getId() != null) {
        //TODO: throw exception and force the caller to call update instead
        update(mergedAnomalyResultDTO);
        return mergedAnomalyResultDTO.getId();
    }
    MergedAnomalyResultBean mergeAnomalyBean = convertMergeAnomalyDTO2Bean(mergedAnomalyResultDTO);
    Long id = genericPojoDao.put(mergeAnomalyBean);
    mergedAnomalyResultDTO.setId(id);
    return id;
}
Also used : MergedAnomalyResultBean(com.linkedin.thirdeye.datalayer.pojo.MergedAnomalyResultBean)

Example 4 with MergedAnomalyResultBean

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

the class MergedAnomalyResultManagerImpl method findByFunctionIdAndIdGreaterThan.

@Override
public List<MergedAnomalyResultDTO> findByFunctionIdAndIdGreaterThan(Long functionId, Long anomalyId) {
    Predicate predicate = Predicate.AND(Predicate.EQ("functionId", functionId), Predicate.GT("baseId", anomalyId));
    List<MergedAnomalyResultBean> list = genericPojoDao.get(predicate, MergedAnomalyResultBean.class);
    return batchConvertMergedAnomalyBean2DTO(list, true);
}
Also used : MergedAnomalyResultBean(com.linkedin.thirdeye.datalayer.pojo.MergedAnomalyResultBean) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 5 with MergedAnomalyResultBean

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

the class MergedAnomalyResultManagerImpl method getAllByTimeEmailIdAndNotifiedFalse.

@Override
public List<MergedAnomalyResultDTO> getAllByTimeEmailIdAndNotifiedFalse(long startTime, long endTime, long emailConfigId) {
    EmailConfigurationBean emailConfigurationBean = genericPojoDao.get(emailConfigId, EmailConfigurationBean.class);
    List<Long> functionIds = emailConfigurationBean.getFunctionIds();
    if (functionIds == null || functionIds.isEmpty()) {
        return Collections.emptyList();
    }
    Long[] functionIdArray = functionIds.toArray(new Long[] {});
    Predicate predicate = //
    Predicate.AND(//
    Predicate.LT("startTime", endTime), //
    Predicate.GT("endTime", startTime), //
    Predicate.IN("functionId", functionIdArray), //
    Predicate.EQ("notified", false));
    List<MergedAnomalyResultBean> list = genericPojoDao.get(predicate, MergedAnomalyResultBean.class);
    return batchConvertMergedAnomalyBean2DTO(list, true);
}
Also used : MergedAnomalyResultBean(com.linkedin.thirdeye.datalayer.pojo.MergedAnomalyResultBean) EmailConfigurationBean(com.linkedin.thirdeye.datalayer.pojo.EmailConfigurationBean) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Aggregations

MergedAnomalyResultBean (com.linkedin.thirdeye.datalayer.pojo.MergedAnomalyResultBean)13 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)7 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)2 ArrayList (java.util.ArrayList)2 RawAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO)1 AnomalyFeedbackBean (com.linkedin.thirdeye.datalayer.pojo.AnomalyFeedbackBean)1 EmailConfigurationBean (com.linkedin.thirdeye.datalayer.pojo.EmailConfigurationBean)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1