use of com.thinkbiganalytics.metadata.api.feed.FeedSummary in project kylo by Teradata.
the class FeedHealthSummaryCache method getUserFeedHealth.
public SearchResult getUserFeedHealth(Long time, FeedSummaryFilter feedSummaryFilter, RoleSetExposingSecurityExpressionRoot userContext) {
SearchResult<com.thinkbiganalytics.jobrepo.query.model.FeedSummary> searchResult = new SearchResultImpl();
List<FeedHealth> feedSummaryHealth = null;
// get the entire list back and filter it for user access
List<? extends FeedSummary> list = getFeedSummaryList(time).stream().filter(filter(feedSummaryFilter, userContext)).collect(Collectors.toList());
feedSummaryHealth = list.stream().sorted(feedSummaryFilter.getSort() != null ? getComparator(feedSummaryFilter.getSort()) : byName).skip(feedSummaryFilter.getStart()).limit(feedSummaryFilter.getLimit() > 0 ? feedSummaryFilter.getLimit() : Integer.MAX_VALUE).map(f -> FeedModelTransform.feedHealth(f)).collect(Collectors.toList());
// Transform it to FeedSummary objects
FeedStatus feedStatus = FeedModelTransform.feedStatus(feedSummaryHealth);
Long total = new Long(list.size());
searchResult.setData(feedStatus.getFeedSummary());
searchResult.setRecordsTotal(total);
searchResult.setRecordsFiltered(total);
return searchResult;
}
use of com.thinkbiganalytics.metadata.api.feed.FeedSummary in project kylo by Teradata.
the class FeedHealthSummaryCache method fetchFeedSummary.
private List<? extends FeedSummary> fetchFeedSummary() {
return metadataAccess.read(() -> {
Stopwatch stopwatch = Stopwatch.createStarted();
List<? extends FeedSummary> list = opsManagerFeedProvider.findFeedSummary();
Map<String, FeedSummary> latestFeeds = new HashMap<>();
// NOTE it could also populate the last job execution time since the above query gets a union of the running jobs along with the latest finished jobs by feed
list.stream().sorted(byRunningStatus.thenComparing(byStartTime)).forEach(f -> {
String feedId = f.getFeedId().toString();
if (!latestFeeds.containsKey(feedId)) {
latestFeeds.put(feedId, f);
}
});
// add in initial feeds
List<? extends OpsManagerFeed> allFeeds = opsManagerFeedProvider.findAllWithoutAcl();
allFeeds.stream().filter(f -> !latestFeeds.containsKey(f.getId().toString())).forEach(f -> {
JpaFeedSummary s = new JpaFeedSummary();
s.setStream(f.isStream());
s.setFeedId(UUID.fromString(f.getId().toString()));
s.setFeedName(f.getName());
s.setFeedType(f.getFeedType());
s.setRunningCount(0L);
s.setAbandonedCount(0L);
s.setFailedCount(0L);
s.setAllCount(0L);
s.setCompletedCount(0L);
s.setRunStatus(FeedSummary.RunStatus.INITIAL);
s.setStatus(BatchJobExecution.JobStatus.UNKNOWN);
latestFeeds.put(s.getFeedId().toString(), s);
});
stopwatch.stop();
log.debug("Time to fetchAndDedupe FeedSummary: {} ", stopwatch.elapsed(TimeUnit.MILLISECONDS));
return new ArrayList<>(latestFeeds.values());
}, MetadataAccess.SERVICE);
}
Aggregations