Search in sources :

Example 56 with Feed

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

the class JcrPropertyTest method testMergeProps.

@Test
public void testMergeProps() {
    testFeed();
    Map<String, Object> props = new HashMap<>();
    props.put("name", "An Old User");
    props.put("age", 140);
    Map<String, Object> props2 = metadata.commit(() -> {
        List<? extends Feed> feeds = feedProvider.getFeeds();
        Feed feed = null;
        // grab the first feed
        if (feeds != null) {
            feed = feeds.get(0);
        }
        feedProvider.mergeFeedProperties(feed.getId(), props);
        return feed.getProperties();
    }, MetadataAccess.SERVICE);
    props.put("address", "Some road");
    props2 = metadata.commit(() -> {
        List<? extends Feed> feeds = feedProvider.getFeeds();
        Feed feed = null;
        // grab the first feed
        if (feeds != null) {
            feed = feeds.get(0);
        }
        feedProvider.mergeFeedProperties(feed.getId(), props);
        return feed.getProperties();
    }, MetadataAccess.SERVICE);
    org.junit.Assert.assertEquals("Some road", props2.get("address"));
    // Now Replace
    props.remove("address");
    props2 = metadata.commit(() -> {
        List<? extends Feed> feeds = feedProvider.getFeeds();
        Feed feed = null;
        // grab the first feed
        if (feeds != null) {
            feed = feeds.get(0);
        }
        feedProvider.replaceProperties(feed.getId(), props);
        return feed.getProperties();
    }, MetadataAccess.SERVICE);
    Assert.assertNull(props2.get("address"));
}
Also used : HashMap(java.util.HashMap) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) List(java.util.List) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) Test(org.junit.Test)

Example 57 with Feed

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

the class FeedManagerFeedTest method setupFeedAndTemplate.

private void setupFeedAndTemplate(String categorySystemName, String feedName, String templateName) {
    // first create the category
    metadata.commit(() -> {
        Category category = feedTestUtil.findOrCreateCategory(categorySystemName);
        return category.getId();
    }, MetadataAccess.SERVICE);
    // creqte the feed
    metadata.commit(() -> {
        Feed feed = feedTestUtil.findOrCreateFeed(categorySystemName, feedName, templateName);
        return feed.getId();
    }, MetadataAccess.SERVICE);
    // ensure the feed relates to the template
    metadata.read(() -> {
        FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
        List<Feed> feeds = template.getFeeds();
        Assert.assertTrue(feeds != null && feeds.size() > 0);
    }, MetadataAccess.SERVICE);
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 58 with Feed

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

the class FeedManagerFeedTest method testLotsOfFeeds.

/**
 * Test querying a large number of feeds
 */
@Test
public void testLotsOfFeeds() {
    // increase to query more .. i.e. 1000
    int numberOfFeeds = 5;
    int numberOfFeedsPerCategory = 20;
    String templateName = "my_template";
    int categories = numberOfFeeds / numberOfFeedsPerCategory;
    // create all the categories
    metadata.commit(() -> {
        for (int i = 1; i <= categories; i++) {
            Category category = feedTestUtil.createCategory("category_" + i);
        }
    }, MetadataAccess.ADMIN);
    metadata.commit(() -> {
        FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
    }, MetadataAccess.ADMIN);
    // create the feeds
    metadata.commit(() -> {
        FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
        Category category = null;
        int categoryNum = 0;
        String categoryName = "category" + categoryNum;
        for (int i = 0; i < numberOfFeeds; i++) {
            if (i % numberOfFeedsPerCategory == 0) {
                categoryNum++;
                categoryName = "category_" + categoryNum;
                category = feedTestUtil.findOrCreateCategory(categoryName);
            }
            Feed feed = feedTestUtil.findOrCreateFeed(category, "feed_" + i, template);
        }
    }, MetadataAccess.ADMIN);
    // now query it
    long time = System.currentTimeMillis();
    Integer size = metadata.read(() -> {
        List<Feed> feeds = feedProvider.findAll();
        return feeds.size();
    }, MetadataAccess.SERVICE);
    long stopTime = System.currentTimeMillis();
    log.info("Time to query {} feeds was {} ms", size, (stopTime - time));
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) Test(org.junit.Test)

Example 59 with Feed

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

the class FeedTestUtil method findOrCreateFeed.

public Feed findOrCreateFeed(Category category, String feedSystemName, FeedManagerTemplate template) {
    Feed feed = feedProvider.ensureFeed(category.getId(), feedSystemName);
    feed.setDisplayName(feedSystemName);
    feed.setTemplate(template);
    feed.setJson(sampleFeedJson());
    return feedProvider.update(feed);
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 60 with Feed

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

the class FeedTestUtil method findOrCreateFeed.

public Feed findOrCreateFeed(String categorySystemName, String feedSystemName, String feedTemplate) {
    Category category = findOrCreateCategory(categorySystemName);
    Feed feed = feedProvider.ensureFeed(category.getId(), feedSystemName);
    feed.setDisplayName(feedSystemName);
    FeedManagerTemplate template = findOrCreateTemplate(feedTemplate);
    feed.setTemplate(template);
    return feedProvider.update(feed);
}
Also used : JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) Category(com.thinkbiganalytics.metadata.api.category.Category) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) 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