Search in sources :

Example 1 with FeedSummary

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;
}
Also used : SearchResultImpl(com.thinkbiganalytics.rest.model.search.SearchResultImpl) FeedStatus(com.thinkbiganalytics.jobrepo.query.model.FeedStatus) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) JpaFeedSummary(com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary) FeedSummary(com.thinkbiganalytics.metadata.api.feed.FeedSummary)

Example 2 with FeedSummary

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);
}
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) 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

FeedHealth (com.thinkbiganalytics.jobrepo.query.model.FeedHealth)2 FeedStatus (com.thinkbiganalytics.jobrepo.query.model.FeedStatus)2 FeedSummary (com.thinkbiganalytics.metadata.api.feed.FeedSummary)2 JpaFeedSummary (com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary)2 SearchResultImpl (com.thinkbiganalytics.rest.model.search.SearchResultImpl)2 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 FeedModelTransform (com.thinkbiganalytics.jobrepo.query.model.transform.FeedModelTransform)1 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)1 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)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 FeedAclCache (com.thinkbiganalytics.metadata.jpa.feed.security.FeedAclCache)1