use of com.thinkbiganalytics.alerts.api.core.BaseAlertCriteria in project kylo by Teradata.
the class InMemoryAlertManager method getAlertsSummary.
@Override
public Iterator<AlertSummary> getAlertsSummary(AlertCriteria criteria) {
BaseAlertCriteria predicate = (BaseAlertCriteria) (criteria == null ? criteria() : criteria);
// TODO Grab a partition of the map first based on before/after times of criteria
List<Alert> alerts = this.alertsByTime.values().stream().map(ref -> (Alert) ref.get()).filter(predicate).collect(Collectors.toList());
List<AlertSummary> summaryList = new ArrayList<>();
Map<String, AlertSummary> groupedAlerts = new HashMap<>();
alerts.stream().forEach(alert -> {
String key = alert.getType() + ":" + alert.getSubtype() + ":" + alert.getLevel();
groupedAlerts.computeIfAbsent(key, groupKey -> new GenericAlertSummary(alert.getType().toString(), alert.getSubtype(), alert.getLevel()));
((GenericAlertSummary) groupedAlerts.get(key)).incrementCount();
});
return groupedAlerts.values().iterator();
}
Aggregations