Search in sources :

Example 1 with JpaFeedSummary

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);
}
Also used : LoadingCache(com.google.common.cache.LoadingCache) SearchResultImpl(com.thinkbiganalytics.rest.model.search.SearchResultImpl) Stopwatch(com.google.common.base.Stopwatch) LoggerFactory(org.slf4j.LoggerFactory) DateTimeUtil(com.thinkbiganalytics.DateTimeUtil) HashMap(java.util.HashMap) FeedAclCache(com.thinkbiganalytics.metadata.jpa.feed.security.FeedAclCache) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) RoleSetExposingSecurityExpressionRoot(com.thinkbiganalytics.metadata.config.RoleSetExposingSecurityExpressionRoot) Map(java.util.Map) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) AtomicLongMap(com.google.common.util.concurrent.AtomicLongMap) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) OpsManagerFeedProvider(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeedProvider) Logger(org.slf4j.Logger) NullSafeComparator(org.springframework.util.comparator.NullSafeComparator) FeedStatus(com.thinkbiganalytics.jobrepo.query.model.FeedStatus) Predicate(java.util.function.Predicate) TimeUtil(com.thinkbiganalytics.metadata.cache.util.TimeUtil) UUID(java.util.UUID) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) SearchResult(com.thinkbiganalytics.rest.model.search.SearchResult) Collectors(java.util.stream.Collectors) JpaFeedSummary(com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary) CacheLoader(com.google.common.cache.CacheLoader) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) FeedModelTransform(com.thinkbiganalytics.jobrepo.query.model.transform.FeedModelTransform) CacheBuilder(com.google.common.cache.CacheBuilder) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) Comparator(java.util.Comparator) FeedSummary(com.thinkbiganalytics.metadata.api.feed.FeedSummary) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) HashMap(java.util.HashMap) Stopwatch(com.google.common.base.Stopwatch) JpaFeedSummary(com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary) ArrayList(java.util.ArrayList) JpaFeedSummary(com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary) FeedSummary(com.thinkbiganalytics.metadata.api.feed.FeedSummary)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1 AtomicLongMap (com.google.common.util.concurrent.AtomicLongMap)1 DateTimeUtil (com.thinkbiganalytics.DateTimeUtil)1 FeedHealth (com.thinkbiganalytics.jobrepo.query.model.FeedHealth)1 FeedStatus (com.thinkbiganalytics.jobrepo.query.model.FeedStatus)1 FeedModelTransform (com.thinkbiganalytics.jobrepo.query.model.transform.FeedModelTransform)1 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)1 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)1 FeedSummary (com.thinkbiganalytics.metadata.api.feed.FeedSummary)1 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)1 OpsManagerFeedProvider (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeedProvider)1 BatchJobExecution (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution)1 TimeUtil (com.thinkbiganalytics.metadata.cache.util.TimeUtil)1 RoleSetExposingSecurityExpressionRoot (com.thinkbiganalytics.metadata.config.RoleSetExposingSecurityExpressionRoot)1 JpaFeedSummary (com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary)1 FeedAclCache (com.thinkbiganalytics.metadata.jpa.feed.security.FeedAclCache)1 SearchResult (com.thinkbiganalytics.rest.model.search.SearchResult)1