use of com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary 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().filter(f -> ((FeedSummary) f).getFeedType().equals(OpsManagerFeed.FeedType.FEED)).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()) && ((OpsManagerFeed) f).getFeedType().equals(OpsManagerFeed.FeedType.FEED)).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