Search in sources :

Example 1 with EventDTO

use of com.linkedin.thirdeye.datalayer.dto.EventDTO in project pinot by linkedin.

the class HistoricalAnomalyEventProvider method getAnomalyEvent.

private EventDTO getAnomalyEvent(MergedAnomalyResultDTO anomalyResultDTO) {
    EventDTO eventDTO = new EventDTO();
    eventDTO.setEventType(EventType.HISTORICAL_ANOMALY.name());
    eventDTO.setStartTime(anomalyResultDTO.getStartTime());
    eventDTO.setEndTime(anomalyResultDTO.getEndTime());
    eventDTO.setMetric(anomalyResultDTO.getMetric());
    eventDTO.setId(anomalyResultDTO.getId());
    Map<String, List<String>> dimensionValuesMap = new HashMap<>();
    if (anomalyResultDTO.getDimensions() != null && anomalyResultDTO.getDimensions().size() > 0) {
        for (String dimension : anomalyResultDTO.getDimensions().keySet()) {
            dimensionValuesMap.putIfAbsent(dimension, new ArrayList<>());
            dimensionValuesMap.get(dimension).add(anomalyResultDTO.getDimensions().get(dimension));
        }
    }
    eventDTO.setTargetDimensionMap(dimensionValuesMap);
    return eventDTO;
}
Also used : HashMap(java.util.HashMap) EventDTO(com.linkedin.thirdeye.datalayer.dto.EventDTO) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with EventDTO

use of com.linkedin.thirdeye.datalayer.dto.EventDTO in project pinot by linkedin.

the class HistoricalAnomalyEventProvider method getEvents.

@Override
public List<EventDTO> getEvents(EventFilter eventFilter) {
    List<MergedAnomalyResultDTO> mergedAnomalies;
    List<EventDTO> events = new ArrayList<>();
    if (eventFilter.getMetricName() == null) {
        mergedAnomalies = mergedAnomalyDAO.findByTime(eventFilter.getStartTime(), eventFilter.getStartTime());
    } else {
        mergedAnomalies = mergedAnomalyDAO.findByMetricTime(eventFilter.getMetricName(), eventFilter.getStartTime(), eventFilter.getStartTime(), false);
    }
    if (mergedAnomalies != null) {
        for (MergedAnomalyResultDTO mergedAnomalyResultDTO : mergedAnomalies) {
            events.add(getAnomalyEvent(mergedAnomalyResultDTO));
        }
    }
    return events;
}
Also used : MergedAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO) ArrayList(java.util.ArrayList) EventDTO(com.linkedin.thirdeye.datalayer.dto.EventDTO)

Example 3 with EventDTO

use of com.linkedin.thirdeye.datalayer.dto.EventDTO in project pinot by linkedin.

the class DefaultHolidayEventProvider method getEvents.

@Override
public List<EventDTO> getEvents(EventFilter eventFilter) {
    List<EventDTO> allEventsBetweenTimeRange = eventDAO.findEventsBetweenTimeRange(EventType.HOLIDAY.name(), eventFilter.getStartTime(), eventFilter.getEndTime());
    if (eventFilter.getTargetDimensionMap() == null || eventFilter.getTargetDimensionMap().size() == 0) {
        return allEventsBetweenTimeRange;
    }
    List<EventDTO> qualifiedDeploymentEvents = new ArrayList<>();
    for (Map.Entry<String, List<String>> dimensionValues : eventFilter.getTargetDimensionMap().entrySet()) {
        String dimension = dimensionValues.getKey();
        List<String> targetValues = dimensionValues.getValue();
        if (dimension.startsWith("country")) {
            for (EventDTO eventDTO : allEventsBetweenTimeRange) {
                for (String target : targetValues) {
                    if (eventDTO.getTargetDimensionMap().get(COUNTRY_CODE).contains(target)) {
                        if (!qualifiedDeploymentEvents.contains(eventDTO)) {
                            qualifiedDeploymentEvents.add(eventDTO);
                        }
                    }
                }
            }
        }
    }
    return qualifiedDeploymentEvents;
}
Also used : EventDTO(com.linkedin.thirdeye.datalayer.dto.EventDTO) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 4 with EventDTO

use of com.linkedin.thirdeye.datalayer.dto.EventDTO in project pinot by linkedin.

the class EventManagerImpl method findEventsBetweenTimeRange.

public List<EventDTO> findEventsBetweenTimeRange(String eventType, long start, long end) {
    Predicate predicate = Predicate.AND(Predicate.EQ("eventType", eventType), Predicate.GT("endTime", start), Predicate.LT("startTime", end));
    List<EventBean> list = genericPojoDao.get(predicate, EventBean.class);
    List<EventDTO> results = new ArrayList<>();
    for (EventBean event : list) {
        EventDTO eventDTO = MODEL_MAPPER.map(event, EventDTO.class);
        results.add(eventDTO);
    }
    return results;
}
Also used : EventBean(com.linkedin.thirdeye.datalayer.pojo.EventBean) ArrayList(java.util.ArrayList) EventDTO(com.linkedin.thirdeye.datalayer.dto.EventDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 5 with EventDTO

use of com.linkedin.thirdeye.datalayer.dto.EventDTO in project pinot by linkedin.

the class EventManagerImpl method findEventsBetweenTimeRangeByName.

public List<EventDTO> findEventsBetweenTimeRangeByName(String eventType, String name, long start, long end) {
    Predicate predicate = Predicate.AND(Predicate.EQ("eventType", eventType), Predicate.EQ("name", name), Predicate.GT("endTime", start), Predicate.LT("startTime", end));
    List<EventBean> list = genericPojoDao.get(predicate, EventBean.class);
    List<EventDTO> results = new ArrayList<>();
    for (EventBean event : list) {
        EventDTO eventDTO = MODEL_MAPPER.map(event, EventDTO.class);
        results.add(eventDTO);
    }
    return results;
}
Also used : EventBean(com.linkedin.thirdeye.datalayer.pojo.EventBean) ArrayList(java.util.ArrayList) EventDTO(com.linkedin.thirdeye.datalayer.dto.EventDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Aggregations

EventDTO (com.linkedin.thirdeye.datalayer.dto.EventDTO)11 ArrayList (java.util.ArrayList)8 List (java.util.List)4 EventBean (com.linkedin.thirdeye.datalayer.pojo.EventBean)3 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)3 HashMap (java.util.HashMap)3 Test (org.testng.annotations.Test)3 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)1 Map (java.util.Map)1 DateTime (org.joda.time.DateTime)1