Search in sources :

Example 91 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class IntegrationTestBase method makeCreateFeedRequest.

protected FeedMetadata makeCreateFeedRequest(FeedCategory category, ImportTemplate template, String feedName, String testFile) {
    FeedMetadata feed = new FeedMetadata();
    feed.setFeedName(feedName);
    feed.setSystemFeedName(feedName.toLowerCase());
    feed.setCategory(category);
    feed.setTemplateId(template.getTemplateId());
    feed.setTemplateName(template.getTemplateName());
    feed.setDescription("Created by functional test");
    feed.setInputProcessorType("org.apache.nifi.processors.standard.GetFile");
    List<NifiProperty> properties = new ArrayList<>();
    NifiProperty fileFilter = new NifiProperty("764d053d-015e-1000-b8a2-763cd17080e1", "cffa8f24-d097-3c7a-7d04-26b7feff81ab", "File Filter", testFile);
    fileFilter.setProcessGroupName("NiFi Flow");
    fileFilter.setProcessorName("GetFile");
    fileFilter.setProcessorType("org.apache.nifi.processors.standard.GetFile");
    fileFilter.setTemplateValue("mydata\\d{1,3}.csv");
    fileFilter.setInputProperty(true);
    fileFilter.setUserEditable(true);
    properties.add(fileFilter);
    feed.setProperties(properties);
    FeedSchedule schedule = new FeedSchedule();
    schedule.setConcurrentTasks(1);
    schedule.setSchedulingPeriod("15 sec");
    schedule.setSchedulingStrategy("TIMER_DRIVEN");
    feed.setSchedule(schedule);
    feed.setDataOwner("Marketing");
    List<Tag> tags = new ArrayList<>();
    tags.add(new DefaultTag("functional tests"));
    tags.add(new DefaultTag("for category " + category.getName()));
    feed.setTags(tags);
    User owner = new User();
    owner.setSystemName("dladmin");
    owner.setDisplayName("Data Lake Admin");
    Set<String> groups = new HashSet<>();
    groups.add("admin");
    groups.add("user");
    owner.setGroups(groups);
    feed.setOwner(owner);
    return feed;
}
Also used : User(com.thinkbiganalytics.security.rest.model.User) FeedSchedule(com.thinkbiganalytics.feedmgr.rest.model.FeedSchedule) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) ArrayList(java.util.ArrayList) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) Tag(com.thinkbiganalytics.discovery.schema.Tag) DefaultTag(com.thinkbiganalytics.discovery.model.DefaultTag) DefaultTag(com.thinkbiganalytics.discovery.model.DefaultTag) HashSet(java.util.HashSet)

Example 92 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class FeedLoadTest method loadTest.

/**
 * Bulk load a template into NiFi and Kylo
 * categories are named  'category_#
 * feeds are named  cat_#_feedName_#
 *
 * @param templatePath the template to use
 * @param feedName the name of the feed
 * @param categories the number of categories to use/create
 * @param feedsInCategory the number of feeds to create in each category
 * @param startingCategoryId the category number to use for the first category
 * @throws Exception
 */
private void loadTest(String templatePath, String feedName, int categories, int feedsInCategory, int startingCategoryId) throws Exception {
    ImportTemplate ingestTemplate = importTemplate(templatePath);
    for (int i = startingCategoryId; i < (startingCategoryId + categories); i++) {
        // create new category
        String categoryName = "category_" + i;
        FeedCategory category = getorCreateCategoryByName(categoryName);
        Integer maxFeedId = category.getRelatedFeeds();
        maxFeedId += 1;
        for (int j = maxFeedId; j < (feedsInCategory + maxFeedId); j++) {
            try {
                String updateFeedName = "cat_" + i + "_" + feedName + "_" + j;
                FeedMetadata feed = getCreateFeedRequest(category, ingestTemplate, updateFeedName);
                long start = System.currentTimeMillis();
                FeedMetadata response = createFeed(feed).getFeedMetadata();
                LOG.info("Time to save: {} was: {} ms ", updateFeedName, (System.currentTimeMillis() - start));
            } catch (Exception e) {
            }
        }
    }
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) ImportTemplate(com.thinkbiganalytics.feedmgr.service.template.importing.model.ImportTemplate)

Example 93 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class EntityLevelAccessIT method getEditFeedRequest.

private FeedMetadata getEditFeedRequest() {
    FeedMetadata editFeedRequest = makeCreateFeedRequest(category, template, feed.getFeedName(), TEST_FILE);
    editFeedRequest.setId(feed.getId());
    editFeedRequest.setFeedId(feed.getFeedId());
    editFeedRequest.setDescription("New Description");
    editFeedRequest.setIsNew(false);
    return editFeedRequest;
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)

Example 94 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class EntityLevelAccessIT method assertAnalystCanEditFeed.

private void assertAnalystCanEditFeed() {
    LOG.debug("EntityLevelAccessIT.assertAnalystCanEditFeed");
    runAs(ANALYST);
    FeedMetadata editFeedRequest = getEditFeedRequest();
    NifiFeed feed = createFeed(editFeedRequest);
    Assert.assertTrue(feed.getErrorMessages() == null);
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)

Example 95 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class EntityLevelAccessIT method assertAnalystCantEditFeed.

private void assertAnalystCantEditFeed(String[] errorMessages) {
    LOG.debug("EntityLevelAccessIT.assertAnalystCantEditFeed");
    runAs(ANALYST);
    FeedMetadata editFeedRequest = getEditFeedRequest();
    NifiFeed feed = createFeed(editFeedRequest);
    LOG.debug("EntityLevelAccessIT.assertAnalystCantEditFeed - asserting analyst cant create the feed");
    if (feed.getErrorMessages() != null && feed.getErrorMessages().get(0) != null) {
        LOG.debug("Analyst feed error message is {}.", feed.getErrorMessages().get(0));
    }
    Assert.assertEquals(1, feed.getErrorMessages().size());
    Assert.assertTrue(Arrays.asList(errorMessages).stream().anyMatch(msg -> feed.getErrorMessages().get(0).startsWith(msg)));
}
Also used : IntegrationTestBase(com.thinkbiganalytics.integration.IntegrationTestBase) Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) ANALYST(com.thinkbiganalytics.integration.UserContext.User.ANALYST) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) Response(com.jayway.restassured.response.Response) HTTP_OK(java.net.HttpURLConnection.HTTP_OK) FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) RestResponseStatus(com.thinkbiganalytics.rest.model.RestResponseStatus) UserGroup(com.thinkbiganalytics.security.rest.model.UserGroup) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) FeedServicesAccessControl(com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) FeedCategoryRestController(com.thinkbiganalytics.feedmgr.rest.controller.FeedCategoryRestController) Logger(org.slf4j.Logger) ImportTemplate(com.thinkbiganalytics.feedmgr.service.template.importing.model.ImportTemplate) PermissionsChange(com.thinkbiganalytics.security.rest.model.PermissionsChange) ActionGroup(com.thinkbiganalytics.security.rest.model.ActionGroup) Test(org.junit.Test) Action(com.thinkbiganalytics.security.rest.model.Action) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary) RoleMembership(com.thinkbiganalytics.security.rest.model.RoleMembership) ADMIN(com.thinkbiganalytics.integration.UserContext.User.ADMIN) Assert(org.junit.Assert) HTTP_FORBIDDEN(java.net.HttpURLConnection.HTTP_FORBIDDEN) RoleMembershipChange(com.thinkbiganalytics.security.rest.model.RoleMembershipChange) HTTP_NOT_FOUND(java.net.HttpURLConnection.HTTP_NOT_FOUND) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)

Aggregations

FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)96 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)36 ArrayList (java.util.ArrayList)35 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)32 List (java.util.List)30 Map (java.util.Map)30 Collectors (java.util.stream.Collectors)30 Set (java.util.Set)28 StringUtils (org.apache.commons.lang3.StringUtils)28 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)27 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)27 Logger (org.slf4j.Logger)27 LoggerFactory (org.slf4j.LoggerFactory)27 HashSet (java.util.HashSet)26 Inject (javax.inject.Inject)25 Nonnull (javax.annotation.Nonnull)24 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)23 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)23 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)23 AccessController (com.thinkbiganalytics.security.AccessController)23