Search in sources :

Example 31 with Feed

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

the class HistoryDataReindexingFeedsAvailableCache method updateInfoFlagsForReindexFeed.

private void updateInfoFlagsForReindexFeed() {
    metadataAccess.read(() -> {
        Feed historyReindexFeed = feedProvider.findBySystemName(historyDataReindexingReindexFeedCategory, historyDataReindexingReindexFeedSystemName);
        if (historyReindexFeed == null) {
            reindexFeedAvailableWithMatchingName = false;
            reindexFeedAvailableWithMatchingProperty = false;
        } else {
            reindexFeedAvailableWithMatchingName = true;
            if (!historyReindexFeed.getUserProperties().isEmpty() && historyReindexFeed.getUserProperties().containsKey(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK) && historyReindexFeed.getUserProperties().get(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK).equals(REINDEX_SUPPORT_PROPERTY_VALUE_FOR_CHECK)) {
                reindexFeedAvailableWithMatchingProperty = true;
                log.info("Feed supporting history data reindexing (reindex feed) found in Kylo");
            } else {
                reindexFeedAvailableWithMatchingProperty = false;
            }
        }
    }, MetadataAccess.SERVICE);
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 32 with Feed

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

the class HistoryDataReindexingFeedsAvailableCache method updateInfoFlagsForRegularFeed.

private void updateInfoFlagsForRegularFeed() {
    metadataAccess.read(() -> {
        Feed regularIndexFeed = feedProvider.findBySystemName(historyDataReindexingRegularFeedCategory, historyDataReindexingRegularFeedSystemName);
        if (regularIndexFeed == null) {
            regularFeedAvailableWithMatchingName = false;
            regularFeedAvailableWithMatchingProperty = false;
        } else {
            regularFeedAvailableWithMatchingName = true;
            if (!regularIndexFeed.getUserProperties().isEmpty() && regularIndexFeed.getUserProperties().containsKey(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK) && regularIndexFeed.getUserProperties().get(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK).equals(REINDEX_SUPPORT_PROPERTY_VALUE_FOR_CHECK)) {
                regularFeedAvailableWithMatchingProperty = true;
                log.info("Feed supporting history data reindexing (regular feed) found in Kylo");
            } else {
                regularFeedAvailableWithMatchingProperty = false;
            }
        }
    }, MetadataAccess.SERVICE);
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 33 with Feed

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

the class TemplateModelTransform method DOMAIN_TO_REGISTERED_TEMPLATE.

public final Function<FeedManagerTemplate, RegisteredTemplate> DOMAIN_TO_REGISTERED_TEMPLATE(boolean includeFeedNames, boolean includeEncryptedProperties) {
    return new Function<FeedManagerTemplate, RegisteredTemplate>() {

        @Override
        public RegisteredTemplate apply(FeedManagerTemplate domain) {
            String json = domain.getJson();
            RegisteredTemplate template = deserialize(json, includeEncryptedProperties);
            template.setId(domain.getId().toString());
            template.setState(domain.getState().name());
            template.setNifiTemplateId(domain.getNifiTemplateId());
            template.setAllowPreconditions(domain.isAllowPreconditions());
            List<Feed> feeds = domain.getFeeds();
            template.setFeedsCount(feeds == null ? 0 : feeds.size());
            template.setStream(domain.isStream());
            if (includeFeedNames && feeds != null) {
                template.setFeedNames(feeds.stream().map(feedManagerFeed -> FeedNameUtil.fullName(feedManagerFeed.getCategory().getSystemName(), feedManagerFeed.getName())).collect(Collectors.toSet()));
            }
            if (domain.getCreatedTime() != null) {
                template.setCreateDate(domain.getCreatedTime().toDate());
            }
            if (domain.getModifiedTime() != null) {
                template.setUpdateDate(domain.getModifiedTime().toDate());
            }
            template.setOrder(domain.getOrder());
            template.setTemplateTableOption(domain.getTemplateTableOption());
            securityTransform.applyAccessControl(domain, template);
            return template;
        }
    };
}
Also used : Function(com.google.common.base.Function) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 34 with Feed

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

the class DefaultServiceLevelAgreementService method saveAndScheduleSla.

/**
 * In order to Save an SLA if it is related to a Feed(s) the user needs to have EDIT_DETAILS permission on the Feed(s)
 *
 * @param serviceLevelAgreement the sla to save
 * @param feed                  an option Feed to relate to this SLA.  If this is not present the related feeds are also embedded in the SLA policies.  The Feed is a pointer access to the current
 *                              feed the user is editing if they are creating an SLA from the Feed Details page. If creating an SLA from the main SLA page the feed property will not be populated.
 */
private ServiceLevelAgreement saveAndScheduleSla(ServiceLevelAgreementGroup serviceLevelAgreement, FeedMetadata feed) {
    // ensure user has permissions to edit the SLA
    if (serviceLevelAgreement != null) {
        ServiceLevelAgreementMetricTransformerHelper transformer = new ServiceLevelAgreementMetricTransformerHelper();
        // Read the feeds on the SLA as a Service. Then verify the current user has access to edit these feeds
        List<String> feedsOnSla = metadataAccess.read(() -> {
            List<String> feedIds = new ArrayList<>();
            // all referencing Feeds
            List<String> systemCategoryAndFeedNames = transformer.getCategoryFeedNames(serviceLevelAgreement);
            for (String categoryAndFeed : systemCategoryAndFeedNames) {
                // fetch and update the reference to the sla
                String categoryName = StringUtils.trim(StringUtils.substringBefore(categoryAndFeed, "."));
                String feedName = StringUtils.trim(StringUtils.substringAfterLast(categoryAndFeed, "."));
                Feed feedEntity = feedProvider.findBySystemName(categoryName, feedName);
                if (feedEntity != null) {
                    feedIds.add(feedEntity.getId().toString());
                }
            }
            return feedIds;
        }, MetadataAccess.SERVICE);
        boolean allowedToEdit = feedsOnSla.isEmpty() ? true : feedsOnSla.stream().allMatch(feedId -> feedManagerFeedService.checkFeedPermission(feedId, FeedAccessControl.EDIT_DETAILS));
        if (allowedToEdit) {
            return metadataAccess.commit(() -> {
                // Re read back in the Feeds for this session
                Set<Feed> slaFeeds = new HashSet<Feed>();
                Set<Feed.ID> slaFeedIds = new HashSet<Feed.ID>();
                feedsOnSla.stream().forEach(feedId -> {
                    Feed feedEntity = feedProvider.findById(feedProvider.resolveId(feedId));
                    if (feedEntity != null) {
                        slaFeeds.add(feedEntity);
                        slaFeedIds.add(feedEntity.getId());
                    }
                });
                if (feed != null) {
                    feedManagerFeedService.checkFeedPermission(feed.getId(), FeedAccessControl.EDIT_DETAILS);
                }
                if (feed != null) {
                    transformer.applyFeedNameToCurrentFeedProperties(serviceLevelAgreement, feed.getCategory().getSystemName(), feed.getSystemFeedName());
                }
                ServiceLevelAgreement sla = transformer.getServiceLevelAgreement(serviceLevelAgreement);
                ServiceLevelAgreementBuilder slaBuilder = null;
                com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID existingId = null;
                if (StringUtils.isNotBlank(sla.getId())) {
                    existingId = slaProvider.resolve(sla.getId());
                }
                if (existingId != null) {
                    slaBuilder = slaProvider.builder(existingId);
                } else {
                    slaBuilder = slaProvider.builder();
                }
                slaBuilder.name(sla.getName()).description(sla.getDescription());
                for (com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group : sla.getGroups()) {
                    ObligationGroupBuilder groupBuilder = slaBuilder.obligationGroupBuilder(ObligationGroup.Condition.valueOf(group.getCondition()));
                    for (Obligation o : group.getObligations()) {
                        groupBuilder.obligationBuilder().metric(o.getMetrics()).description(o.getDescription()).build();
                    }
                    groupBuilder.build();
                }
                com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement savedSla = slaBuilder.build();
                List<ServiceLevelAgreementActionConfiguration> actions = transformer.getActionConfigurations(serviceLevelAgreement);
                // now assign the sla checks
                slaProvider.slaCheckBuilder(savedSla.getId()).removeSlaChecks().actionConfigurations(actions).build();
                // relate them
                Set<Feed.ID> feedIds = new HashSet<>();
                FeedServiceLevelAgreementRelationship feedServiceLevelAgreementRelationship = feedSlaProvider.relateFeeds(savedSla, slaFeeds);
                if (feedServiceLevelAgreementRelationship != null && feedServiceLevelAgreementRelationship.getFeeds() != null) {
                    feedIds = feedServiceLevelAgreementRelationship.getFeeds().stream().map(f -> f.getId()).collect(Collectors.toSet());
                }
                Set<VelocityTemplate.ID> velocityTemplates = findVelocityTemplates(serviceLevelAgreement);
                // Update the JPA mapping in Ops Manager for this SLA and its related Feeds
                serviceLevelAgreementDescriptionProvider.updateServiceLevelAgreement(savedSla.getId(), savedSla.getName(), savedSla.getDescription(), feedIds, velocityTemplates);
                com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement restModel = serviceLevelAgreementTransform.toModel(savedSla, slaFeeds, true);
                // schedule it
                serviceLevelAgreementScheduler.scheduleServiceLevelAgreement(savedSla);
                return restModel;
            });
        }
    }
    return null;
}
Also used : ServiceLevelAgreementDescriptionProvider(com.thinkbiganalytics.metadata.api.sla.ServiceLevelAgreementDescriptionProvider) JpaVelocityTemplate(com.thinkbiganalytics.metadata.jpa.common.JpaVelocityTemplate) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) FeedServiceLevelAgreementRelationship(com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) FeedAccessControl(com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl) Map(java.util.Map) AccessController(com.thinkbiganalytics.security.AccessController) FeedServicesAccessControl(com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) PolicyPropertyTypes(com.thinkbiganalytics.policy.PolicyPropertyTypes) Obligation(com.thinkbiganalytics.metadata.rest.model.sla.Obligation) LabelValue(com.thinkbiganalytics.rest.model.LabelValue) ServiceLevelAgreementDescription(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementDescription) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) ServiceLevelAgreementActionTemplate(com.thinkbiganalytics.metadata.api.sla.ServiceLevelAgreementActionTemplate) FeedServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementProvider) AccessControlException(java.security.AccessControlException) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) FeedManagerFeedService(com.thinkbiganalytics.feedmgr.service.feed.FeedManagerFeedService) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) ServicesApplicationStartupListener(com.thinkbiganalytics.app.ServicesApplicationStartupListener) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) ServiceLevelAgreementEmailTemplate(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementEmailTemplate) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) FeedServiceLevelAgreement(com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement) ServiceLevelAgreementActionValidation(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation) ObligationGroup(com.thinkbiganalytics.metadata.sla.api.ObligationGroup) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) Logger(org.slf4j.Logger) DateTime(org.joda.time.DateTime) ServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider) ServiceLevelAgreementActionTemplateProvider(com.thinkbiganalytics.metadata.api.sla.ServiceLevelAgreementActionTemplateProvider) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) VelocityTemplateProvider(com.thinkbiganalytics.common.velocity.service.VelocityTemplateProvider) VelocityTemplate(com.thinkbiganalytics.common.velocity.model.VelocityTemplate) ServiceLevelAgreementScheduler(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementScheduler) Collections(java.util.Collections) Obligation(com.thinkbiganalytics.metadata.rest.model.sla.Obligation) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) ArrayList(java.util.ArrayList) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) HashSet(java.util.HashSet) FeedServiceLevelAgreement(com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) FeedServiceLevelAgreementRelationship(com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)

Example 35 with Feed

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

the class FeedWaterMarkService method cancelActiveWaterMark.

public void cancelActiveWaterMark(String feedId, String waterMarkName) {
    com.thinkbiganalytics.metadata.api.feed.Feed.ID updId = this.metadata.read(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
        com.thinkbiganalytics.metadata.api.feed.Feed.ID id = feedProvider.resolveFeed(feedId);
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(id);
        if (feed != null) {
            return feed.getId();
        } else {
            throw new FeedNotFoundException(id);
        }
    });
    cancelActiveWaterMark(updId, waterMarkName);
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Aggregations

Feed (com.thinkbiganalytics.metadata.api.feed.Feed)69 ArrayList (java.util.ArrayList)19 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)17 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)15 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)15 Category (com.thinkbiganalytics.metadata.api.category.Category)14 FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)14 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)13 List (java.util.List)13 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)12 HashMap (java.util.HashMap)12 DateTime (org.joda.time.DateTime)12 ID (com.thinkbiganalytics.metadata.api.feed.Feed.ID)11 Collectors (java.util.stream.Collectors)11 Inject (javax.inject.Inject)11 Test (org.junit.Test)11 FeedAccessControl (com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl)10 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)10 AccessController (com.thinkbiganalytics.security.AccessController)10 HashSet (java.util.HashSet)10