Search in sources :

Example 16 with JcrFeed

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

the class RemoveDuplicateOpsManagerFeedsUpgradeAction method upgradeTo.

@Override
public void upgradeTo(final KyloVersion startingVersion) {
    log.info("remove duplicate ops manager feeds from version: {}", startingVersion);
    List<? extends OpsManagerFeed> feeds = opsManagerFeedProvider.findFeedsWithSameName();
    if (feeds != null) {
        final List<OpsManagerFeed> feedsToDelete = new ArrayList<>();
        final Map<String, OpsManagerFeed> feedsToKeep = new HashMap<>();
        feeds.stream().forEach(feed -> {
            log.info("Found duplicate feed {} - {} ", feed.getId(), feed.getName());
            Feed jcrFeed = feedProvider.getFeed(feed.getId());
            if (jcrFeed == null) {
                feedsToDelete.add(feed);
            } else {
                feedsToKeep.put(feed.getName(), feed);
            }
        });
        feedsToDelete.stream().forEach(feed -> {
            OpsManagerFeed feedToKeep = feedsToKeep.get(feed.getName());
            if (feedToKeep != null) {
                // remove it
                log.info("Unable to find feed {} - {} in JCR metadata.  A feed with id of {} already exists with this same name {}.  Attempt to remove its data from Operations Manager", feed.getId(), feed.getName(), feedToKeep.getId(), feedToKeep.getName());
                opsManagerFeedProvider.delete(feed.getId());
            }
        });
    }
}
Also used : OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)

Aggregations

JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)16 Node (javax.jcr.Node)8 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)7 Test (org.junit.Test)4 JcrCategory (com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)3 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)3 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)3 HashMap (java.util.HashMap)3 Category (com.thinkbiganalytics.metadata.api.category.Category)2 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement)2 FeedServiceLevelAgreementRelationship (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)2 UpgradeException (com.thinkbiganalytics.server.upgrade.UpgradeException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Session (javax.jcr.Session)2 ExtensibleEntity (com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity)1 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)1 FeedSource (com.thinkbiganalytics.metadata.api.feed.FeedSource)1 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)1 FeedOpsAccessControlProvider (com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAccessControlProvider)1