Search in sources :

Example 46 with NifiProperty

use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.

the class NifiRestTest method testUpdateProcessor.

// @Test
public void testUpdateProcessor() {
    NifiProperty p = new NifiProperty();
    p.setProcessGroupId("0b013850-d6bb-44e4-87c2-1784858e60ab");
    p.setProcessorId("795509d5-1433-4e64-b7bd-d05c6adfb95a");
    p.setKey("Source Database Connection");
    p.setValue("4688ee71-262c-46bc-af35-9e9825507160");
    restClient.updateProcessorProperty(p.getProcessGroupId(), p.getProcessorId(), p);
    int i = 0;
}
Also used : NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty)

Example 47 with NifiProperty

use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.

the class NifiRestTest method testLoad.

// @Test
public void testLoad() {
    // setup constants for the test
    String templateName = "Data Ingest";
    int num = 10;
    String processGroupName = "LoadTest";
    String feedPrefix = "LT_";
    String inputType = "org.apache.nifi.processors.standard.GetFile";
    List<NifiProperty> templateProperties = new ArrayList<>();
    String schedulePeriod = "10 sec";
    String GET_FILE_PROCESSOR_NAME = "Poll filesystem";
    String UPDATE_PARAMETERS_PROCESSOR_NAME = "Update flow parameters";
    String INPUT_DIRECTORY_PROPERTY = "Input Directory";
    String SOURCE_PROPERTY = "source";
    String ENTITY_PROPERTY = "entity";
    try {
        TemplateDTO template = restClient.getTemplateByName(templateName);
        List<NifiProperty> propertyList = restClient.getPropertiesForTemplate(template.getId(), true);
        NifiProperty inputDirectory = NifiPropertyUtil.getProperty(GET_FILE_PROCESSOR_NAME, INPUT_DIRECTORY_PROPERTY, propertyList);
        NifiProperty entity = NifiPropertyUtil.getProperty(UPDATE_PARAMETERS_PROCESSOR_NAME, SOURCE_PROPERTY, propertyList);
        NifiProperty source = NifiPropertyUtil.getProperty(UPDATE_PARAMETERS_PROCESSOR_NAME, ENTITY_PROPERTY, propertyList);
        templateProperties.add(inputDirectory);
        templateProperties.add(entity);
        templateProperties.add(source);
        NifiProcessorSchedule schedule = new NifiProcessorSchedule();
        schedule.setSchedulingStrategy("TIMER_DRIVEN");
        schedule.setSchedulingPeriod(schedulePeriod);
        for (int i = 0; i < num; i++) {
            String feedName = feedPrefix + i;
            List<NifiProperty> instanceProperties = NifiPropertyUtil.copyProperties(templateProperties);
            // update the properties
            NifiPropertyUtil.getProperty(GET_FILE_PROCESSOR_NAME, INPUT_DIRECTORY_PROPERTY, instanceProperties).setValue("/tmp/" + feedName);
            NifiPropertyUtil.getProperty(UPDATE_PARAMETERS_PROCESSOR_NAME, SOURCE_PROPERTY, instanceProperties).setValue(processGroupName);
            NifiPropertyUtil.getProperty(UPDATE_PARAMETERS_PROCESSOR_NAME, ENTITY_PROPERTY, instanceProperties).setValue(feedName);
            FeedMetadata feedMetadata = new FeedMetadata();
            feedMetadata.setCategory(new FeedCategory());
            feedMetadata.getCategory().setSystemName(processGroupName);
            feedMetadata.setSystemFeedName("feedPrefix + i");
            CreateFeedBuilder.newFeed(restClient, nifiFlowCache, feedMetadata, template.getId(), new PropertyExpressionResolver(), propertyDescriptorTransform, createFeedBuilderCache, templateConnectionUtil).inputProcessorType(inputType).feedSchedule(schedule).properties(instanceProperties).build();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) ArrayList(java.util.ArrayList) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) PropertyExpressionResolver(com.thinkbiganalytics.feedmgr.nifi.PropertyExpressionResolver) IOException(java.io.IOException) NifiProcessorSchedule(com.thinkbiganalytics.nifi.rest.model.NifiProcessorSchedule)

Aggregations

NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)47 ArrayList (java.util.ArrayList)22 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)19 Map (java.util.Map)15 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)13 HashMap (java.util.HashMap)13 List (java.util.List)13 HashSet (java.util.HashSet)12 Collectors (java.util.stream.Collectors)12 Nonnull (javax.annotation.Nonnull)12 StringUtils (org.apache.commons.lang3.StringUtils)12 Set (java.util.Set)11 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)11 NifiProcessGroup (com.thinkbiganalytics.nifi.rest.model.NifiProcessGroup)10 Optional (java.util.Optional)10 TemplateDTO (org.apache.nifi.web.api.dto.TemplateDTO)10 LegacyNifiRestClient (com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient)8 NifiError (com.thinkbiganalytics.nifi.rest.model.NifiError)8 Collections (java.util.Collections)7 ControllerServiceDTO (org.apache.nifi.web.api.dto.ControllerServiceDTO)7