use of com.thinkbiganalytics.alerts.api.AlertSummary in project kylo by Teradata.
the class AlertsCache method fetchUnhandledAlerts.
protected List<AlertSummaryGrouped> fetchUnhandledAlerts() {
List<AlertSummary> alerts = new ArrayList<>();
AlertCriteria criteria = alertProvider.criteria();
new AlertCriteriaInput.Builder().state(Alert.State.UNHANDLED).asServiceAccount(true).onlyIfChangesDetected(true).applyToCriteria(criteria);
Iterator<? extends AlertSummary> itr = alertProvider.getAlertsSummary(criteria);
if (itr.hasNext()) {
itr.forEachRemaining(alerts::add);
List<AlertSummaryGrouped> latestAlerts = new ArrayList<>(alertsModel.groupAlertSummaries(alerts));
return latestAlerts;
} else {
return Collections.emptyList();
}
}
use of com.thinkbiganalytics.alerts.api.AlertSummary in project kylo by Teradata.
the class FeedsRestController method getAlerts.
private Collection<AlertSummaryGrouped> getAlerts(final String feedName, final String feedId) {
return metadataAccess.read(() -> {
String derivedFeedId = feedId;
// get necessary feed info
if (StringUtils.isBlank(feedId) && StringUtils.isNotBlank(feedName)) {
// get the feedId for this feed name
OpsManagerFeed feed = opsFeedManagerFeedProvider.findByName(feedName);
if (feed != null) {
derivedFeedId = feed.getId().toString();
}
}
if (StringUtils.isBlank(derivedFeedId)) {
return Collections.emptyList();
}
List<? extends ServiceLevelAgreementDescription> slas = serviceLevelAgreementDescriptionProvider.findForFeed(opsFeedManagerFeedProvider.resolveId(derivedFeedId));
List<String> slaIds = new ArrayList<>();
if (slas != null && !slas.isEmpty()) {
slaIds = slas.stream().map(sla -> sla.getSlaId().toString()).collect(Collectors.toList());
}
List<String> ids = new ArrayList<>();
ids.addAll(slaIds);
ids.add(derivedFeedId);
String filter = ids.stream().collect(Collectors.joining("||"));
List<AlertSummary> alerts = new ArrayList<>();
AlertCriteria criteria = alertProvider.criteria().state(Alert.State.UNHANDLED).orFilter(filter);
alertProvider.getAlertsSummary(criteria).forEachRemaining(alerts::add);
return alertsModel.groupAlertSummaries(alerts);
});
}
Aggregations