Search in sources :

Example 1 with JcrFeed

use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed in project kylo by Teradata.

the class CategoryAndFeedReindexingUpgradeAction method upgradeTo.

@Override
public void upgradeTo(KyloVersion startingVersion) {
    log.info("****************** Start: Category and Feed Reindexing Support Upgrade Action ****************");
    log.info("[REF.A] Upgrading feeds to support (1) allowing/stopping metadata indexing, AND (2) reindexing of history data for version: {}...", startingVersion);
    log.info("Total feeds found for upgrading: {}", feedProvider.getFeeds().size());
    if (feedProvider.getFeeds().isEmpty()) {
        log.warn("No feeds have been found for upgrade!");
    }
    feedProvider.getFeeds().forEach(feed -> {
        JcrFeed jcrFeed = (JcrFeed) feed;
        if ((jcrFeed.getFeedSummary().isPresent()) && (jcrFeed.getFeedData().isPresent())) {
            Node summaryNode = jcrFeed.getFeedSummary().get().getNode();
            Node feedDataNode = jcrFeed.getFeedData().get().getNode();
            try {
                summaryNode.addMixin("tba:indexControlled");
                summaryNode.setProperty("tba:allowIndexing", "Y");
                if (!JcrUtil.hasNode(feedDataNode, "tba:historyReindexing")) {
                    log.info("Feed with id [{}] in category [{}] having name [{}] requires history reindexing support. Adding it.", jcrFeed.getId(), jcrFeed.getCategory().getDisplayName(), jcrFeed.getName());
                    feedDataNode.addNode("tba:historyReindexing", "tba:historyReindexing");
                } else {
                    log.info("Feed with id [{}] in category [{}] having name [{}] already has history reindexing support. Skipping step to add again.", jcrFeed.getId(), jcrFeed.getCategory().getDisplayName(), jcrFeed.getName());
                }
                log.info("Upgraded feed with id [{}] in category [{}] having name [{}]", jcrFeed.getId(), jcrFeed.getCategory().getDisplayName(), jcrFeed.getName());
            } catch (Exception e) {
                log.error("Failed to configure feed {} to (1) support allowing/stopping metadata indexing, AND/OR (2) support reindexing of history data: {}", ((JcrFeed) feed).getName(), e);
                throw new UpgradeException("Failed to configure feed to (1) support allowing/stopping metadata indexing, AND/OR (2) support reindexing of history data: " + summaryNode, e);
            }
        } else {
            log.error("Failed to get summary and/or data node for feed: {}", ((JcrFeed) feed).getName());
            throw new UpgradeException("Failed to get summary and/or data node for feed:" + ((JcrFeed) feed).getName());
        }
    });
    log.info("Completed [REF.A]: Configured feeds to support (1) allowing/stopping metadata indexing, AND (2) reindexing of history data for version: {}", startingVersion);
    log.info("[REF.B] Upgrading categories to support allowing/stopping metadata indexing for version: {}...", startingVersion);
    log.info("Total categories found for upgrading: {}", categoryProvider.findAll().size());
    if (categoryProvider.findAll().isEmpty()) {
        log.warn("No categories have been found for for upgrade!");
    }
    categoryProvider.findAll().forEach(category -> {
        JcrCategory jcrCategory = (JcrCategory) category;
        Node categoryNode = jcrCategory.getNode();
        try {
            categoryNode.addMixin("tba:indexControlled");
            categoryNode.setProperty("tba:allowIndexing", "Y");
            log.info("Upgraded category with id [{}] having name [{}]", jcrCategory.getId(), jcrCategory.getDisplayName());
        } catch (Exception e) {
            log.error("Failed to configure category {} to support allowing/stopping metadata indexing: {}", ((JcrCategory) category).getDisplayName(), e);
            throw new UpgradeException("Failed to configure category to support allowing/stopping metadata indexing: " + categoryNode, e);
        }
    });
    log.info("Completed [REF.B]: Configured categories to support allowing/stopping metadata indexing for version: {}", startingVersion);
    log.info("****************** End: Category and Feed Reindexing Support Upgrade Action ****************");
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) Node(javax.jcr.Node) UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)

Example 2 with JcrFeed

use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed in project kylo by Teradata.

the class FeedSlaUpgradeAction method upgradeFeedSla.

private void upgradeFeedSla(ExtensibleType type) {
    List<ExtensibleEntity> slaRels = entityProvider.getEntities(SLA_REL_TYPE_NAME);
    for (ExtensibleEntity rel : slaRels) {
        ServiceLevelAgreement sla = JcrUtil.getJcrObject(rel.getProperty("sla"), JcrServiceLevelAgreement.class);
        Set<Feed> feeds = rel.getPropertyAsSet("feeds", Node.class).stream().map(JcrFeed::new).collect(Collectors.toSet());
        feedSlaProvider.relateFeeds(sla, feeds);
        entityProvider.deleteEntity(rel.getId());
    }
    this.typeProvider.deleteType(type.getId());
}
Also used : Node(javax.jcr.Node) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)

Example 3 with JcrFeed

use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed in project kylo by Teradata.

the class FeedWeakReferenceUpgradeAction method upgradeTo.

@Override
public void upgradeTo(final KyloVersion targetVersion) {
    log.info("Updating template feed references: {}", targetVersion);
    this.templateProvider.findAll().stream().map(JcrFeedTemplate.class::cast).map(JcrFeedTemplate::getNode).forEach(templateNode -> {
        Set<Node> feedNodes = JcrPropertyUtil.getSetProperty(templateNode, JcrFeedTemplate.FEEDS);
        JcrPropertyUtil.removeAllFromSetProperty(templateNode, JcrFeedTemplate.FEEDS);
        feedNodes.forEach(feedNode -> JcrPropertyUtil.addToSetProperty(templateNode, JcrFeedTemplate.FEEDS, feedNode, true));
    });
    this.feedProvider.findAll().stream().map(JcrFeed.class::cast).map(JcrFeed::getFeedDetails).filter(Optional::isPresent).map(Optional::get).map(FeedDetails::getNode).forEach(detailsNode -> {
        Node templateNode = JcrPropertyUtil.getProperty(detailsNode, FeedDetails.TEMPLATE);
        JcrPropertyUtil.setProperty(detailsNode, FeedDetails.TEMPLATE, null);
        JcrPropertyUtil.setWeakReferenceProperty(detailsNode, FeedDetails.TEMPLATE, templateNode);
    });
}
Also used : JcrFeedTemplate(com.thinkbiganalytics.metadata.modeshape.template.JcrFeedTemplate) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) Optional(java.util.Optional) Node(javax.jcr.Node)

Example 4 with JcrFeed

use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed in project kylo by Teradata.

the class JcrFeedTemplate method getFeeds.

public List<Feed> getFeeds() {
    List<Feed> feeds = new ArrayList<>();
    Set<Node> feedNodes = JcrPropertyUtil.getSetProperty(getNode(), FEEDS);
    for (Node depNode : feedNodes) {
        // TODO: note that feeds instances returned here will not be able to update feed ops
        // access through permission changes to their allowed actions.
        feeds.add(new JcrFeed(depNode, (FeedOpsAccessControlProvider) null));
    }
    return feeds;
}
Also used : JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) FeedOpsAccessControlProvider(com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAccessControlProvider) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)

Example 5 with JcrFeed

use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed in project kylo by Teradata.

the class JcrFeedTemplate method removeFeed.

public boolean removeFeed(Feed feed) {
    JcrFeed jcrFeed = (JcrFeed) feed;
    Node feedNode = jcrFeed.getNode();
    return JcrPropertyUtil.removeFromSetProperty(getNode(), FEEDS, feedNode);
}
Also used : JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) Node(javax.jcr.Node)

Aggregations

JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)26 Node (javax.jcr.Node)13 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)11 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)6 UpgradeException (com.thinkbiganalytics.server.upgrade.UpgradeException)5 JcrCategory (com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)4 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)4 AllowedActions (com.thinkbiganalytics.security.action.AllowedActions)4 SecurityRole (com.thinkbiganalytics.security.role.SecurityRole)4 Principal (java.security.Principal)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Category (com.thinkbiganalytics.metadata.api.category.Category)2 ExtensibleEntity (com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity)2 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)2 FeedSource (com.thinkbiganalytics.metadata.api.feed.FeedSource)2 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)2 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement)2 FeedServiceLevelAgreementRelationship (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)2