Search in sources :

Example 6 with FeedNotFoundException

use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.

the class JobRepoFeedOperationsProvider method getDependentDeltaResults.

@Override
public FeedDependencyDeltaResults getDependentDeltaResults(Feed.ID feedId, Set<String> props) {
    Feed feed = this.feedProvider.getFeed(feedId);
    if (feed != null) {
        String systemFeedName = FeedNameUtil.fullName(feed.getCategory().getSystemName(), feed.getName());
        FeedDependencyDeltaResults results = new FeedDependencyDeltaResults(feed.getId().toString(), systemFeedName);
        // find this feeds latest completion
        BatchJobExecution latest = jobExecutionProvider.findLatestCompletedJobForFeed(systemFeedName);
        // get the dependent feeds
        List<Feed> dependents = feed.getDependentFeeds();
        if (dependents != null) {
            for (Feed depFeed : dependents) {
                String depFeedSystemName = FeedNameUtil.fullName(depFeed.getCategory().getSystemName(), depFeed.getName());
                // find Completed feeds executed since time
                Set<BatchJobExecution> jobs = null;
                if (latest != null) {
                    jobs = (Set<BatchJobExecution>) jobExecutionProvider.findJobsForFeedCompletedSince(depFeedSystemName, latest.getStartTime());
                } else {
                    BatchJobExecution job = jobExecutionProvider.findLatestCompletedJobForFeed(depFeedSystemName);
                    if (job != null) {
                        jobs = new HashSet<>();
                        jobs.add(job);
                    }
                }
                if (jobs != null) {
                    for (BatchJobExecution job : jobs) {
                        DateTime endTime = job.getEndTime();
                        Map<String, String> executionContext = job.getJobExecutionContextAsMap();
                        Map<String, Object> map = new HashMap<>();
                        // filter the map
                        if (executionContext != null) {
                            // add those requested to the results map
                            for (Entry<String, String> entry : executionContext.entrySet()) {
                                if (props == null || props.isEmpty() || props.contains(entry.getKey())) {
                                    map.put(entry.getKey(), entry.getValue());
                                }
                            }
                        }
                        results.addFeedExecutionContext(depFeedSystemName, job.getJobExecutionId(), job.getStartTime(), endTime, map);
                    }
                } else {
                    results.getDependentFeedNames().add(depFeedSystemName);
                }
            }
        }
        return results;
    } else {
        throw new FeedNotFoundException(feedId);
    }
}
Also used : HashMap(java.util.HashMap) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) FeedDependencyDeltaResults(com.thinkbiganalytics.metadata.api.op.FeedDependencyDeltaResults) DateTime(org.joda.time.DateTime) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Aggregations

Feed (com.thinkbiganalytics.metadata.api.feed.Feed)6 FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)6 HadoopAuthorizationService (com.thinkbiganalytics.datalake.authorization.service.HadoopAuthorizationService)1 InvalidOperationException (com.thinkbiganalytics.feedmgr.InvalidOperationException)1 EntityVersion (com.thinkbiganalytics.feedmgr.rest.model.EntityVersion)1 EntityVersionDifference (com.thinkbiganalytics.feedmgr.rest.model.EntityVersionDifference)1 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)1 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)1 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)1 FeedVersions (com.thinkbiganalytics.feedmgr.rest.model.FeedVersions)1 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)1 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)1 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)1 UserFieldCollection (com.thinkbiganalytics.feedmgr.rest.model.UserFieldCollection)1 UserProperty (com.thinkbiganalytics.feedmgr.rest.model.UserProperty)1 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)1 FeedManagerCategoryService (com.thinkbiganalytics.feedmgr.service.category.FeedManagerCategoryService)1 FeedManagerFeedService (com.thinkbiganalytics.feedmgr.service.feed.FeedManagerFeedService)1 FeedModelTransform (com.thinkbiganalytics.feedmgr.service.feed.FeedModelTransform)1 FeedManagerTemplateService (com.thinkbiganalytics.feedmgr.service.template.FeedManagerTemplateService)1