Search in sources :

Example 41 with FeedMetadata

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

the class NifiRestTest method testCreateFeed1.

// @Test
public void testCreateFeed1() {
    TemplateDTO templateDTO = restClient.getTemplateByName("New Data Ingest");
    String inputType = "org.apache.nifi.processors.standard.GetFile";
    NifiProcessorSchedule schedule = new NifiProcessorSchedule();
    schedule.setSchedulingStrategy("TIMER_DRIVEN");
    schedule.setSchedulingPeriod("10 sec");
    String inputPortName = "From Data Ingest Feed";
    String feedOutputPortName = "To Data Ingest";
    FeedMetadata feedMetadata = new FeedMetadata();
    feedMetadata.setCategory(new FeedCategory());
    feedMetadata.getCategory().setSystemName("online");
    feedMetadata.setSystemFeedName("Scotts Feed");
    CreateFeedBuilder.newFeed(restClient, nifiFlowCache, feedMetadata, templateDTO.getId(), new PropertyExpressionResolver(), propertyDescriptorTransform, createFeedBuilderCache, templateConnectionUtil).inputProcessorType(inputType).feedSchedule(schedule).addInputOutputPort(new InputOutputPort(inputPortName, feedOutputPortName)).build();
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) InputOutputPort(com.thinkbiganalytics.nifi.feedmgr.InputOutputPort) PropertyExpressionResolver(com.thinkbiganalytics.feedmgr.nifi.PropertyExpressionResolver) NifiProcessorSchedule(com.thinkbiganalytics.nifi.rest.model.NifiProcessorSchedule)

Example 42 with FeedMetadata

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

the class TableSetupTest method test.

@Test
public void test() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    FeedMetadata feedMetadata = new FeedMetadata();
    feedMetadata.setCategory(new FeedCategory());
    feedMetadata.setTable(new TableSetup());
    feedMetadata.getTable().setTableSchema(new DefaultTableSchema());
    feedMetadata.getTable().getTableSchema().setName("test");
    DefaultField f1 = new DefaultField();
    f1.setName("field1");
    feedMetadata.getTable().getTableSchema().getFields().add(f1);
    String json = mapper.writeValueAsString(feedMetadata);
    FeedMetadata feedMetadata2 = mapper.readValue(json, FeedMetadata.class);
    assertEquals(feedMetadata2.getTable().getTableSchema().getName(), feedMetadata.getTable().getTableSchema().getName());
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) DefaultTableSchema(com.thinkbiganalytics.discovery.model.DefaultTableSchema) DefaultField(com.thinkbiganalytics.discovery.model.DefaultField) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 43 with FeedMetadata

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

the class FeedManagerMetadataService method disableFeed.

public FeedSummary disableFeed(final String feedId) {
    return metadataAccess.commit(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
        FeedMetadata feedMetadata = feedProvider.getFeedById(feedId);
        if (feedMetadata == null) {
            throw new NotFoundException("Feed not found for id " + feedId);
        }
        if (!feedMetadata.getState().equals(Feed.State.DISABLED.name())) {
            FeedSummary feedSummary = feedProvider.disableFeed(feedId);
            boolean updatedNifi = updateNifiFeedRunningStatus(feedSummary, Feed.State.DISABLED);
            if (!updatedNifi) {
                // rollback
                throw new RuntimeException("Unable to disable Feed " + feedId);
            }
            return feedSummary;
        }
        return new FeedSummary(feedMetadata);
    });
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NotFoundException(javax.ws.rs.NotFoundException) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Example 44 with FeedMetadata

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

the class FileObjectPersistence method getFeedsFromFile.

public Collection<FeedMetadata> getFeedsFromFile() {
    ObjectMapper mapper = new ObjectMapper();
    File file = new File(filePath + "/" + FEED_METADATA_FILENAME);
    Collection<FeedMetadata> feeds = null;
    if (file.exists()) {
        try {
            feeds = mapper.readValue(file, new TypeReference<List<FeedMetadata>>() {
            });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return feeds;
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 45 with FeedMetadata

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

the class DefaultFeedManagerFeedService method enableFeed.

private boolean enableFeed(final Feed.ID feedId) {
    return metadataAccess.commit(() -> {
        boolean enabled = feedProvider.enableFeed(feedId);
        Feed domainFeed = feedProvider.findById(feedId);
        if (domainFeed != null) {
            domainFeed.setState(Feed.State.ENABLED);
            feedProvider.update(domainFeed);
            if (enabled) {
                FeedMetadata feedMetadata = feedModelTransform.domainToFeedMetadata(domainFeed);
                notifyFeedStateChange(feedMetadata, feedId, Feed.State.ENABLED, MetadataChange.ChangeType.UPDATE);
            }
        }
        return enabled;
    });
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) UIFeed(com.thinkbiganalytics.feedmgr.rest.model.UIFeed)

Aggregations

FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)76 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)26 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)23 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)21 ArrayList (java.util.ArrayList)21 List (java.util.List)20 Collectors (java.util.stream.Collectors)20 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)18 Set (java.util.Set)18 StringUtils (org.apache.commons.lang3.StringUtils)18 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)17 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)17 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)16 Map (java.util.Map)16 Inject (javax.inject.Inject)16 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)15 AccessController (com.thinkbiganalytics.security.AccessController)15 Optional (java.util.Optional)15