Search in sources :

Example 6 with ProcessorDTO

use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.

the class DefaultNiFiFlowVisitorClient method getProcessorsForFlow.

public Set<ProcessorDTO> getProcessorsForFlow(String processGroupId) throws NifiComponentNotFoundException {
    NifiVisitableProcessGroup group = getFlowOrder(processGroupId, null);
    Set<ProcessorDTO> processors = new HashSet<>();
    for (NifiVisitableProcessor p : group.getStartingProcessors()) {
        processors.addAll(p.getProcessors());
    }
    return processors;
}
Also used : NifiVisitableProcessor(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessor) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) HashSet(java.util.HashSet)

Example 7 with ProcessorDTO

use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.

the class DefaultNiFiFlowVisitorClient method getTemplateFeedFlow.

public NifiFlowProcessGroup getTemplateFeedFlow(TemplateDTO template) {
    ProcessGroupDTO parentProcessGroup = new ProcessGroupDTO();
    parentProcessGroup.setId(UUID.randomUUID().toString());
    parentProcessGroup.setParentGroupId(UUID.randomUUID().toString());
    parentProcessGroup.setName(template.getName());
    parentProcessGroup.setContents(template.getSnippet());
    NifiConnectionOrderVisitorCache cache = new NifiConnectionOrderVisitorCache();
    Collection<ProcessGroupDTO> groups = NifiProcessUtil.getProcessGroups(parentProcessGroup);
    cache.add(parentProcessGroup);
    // add the snippet as its own process group
    if (template.getSnippet().getProcessors() != null) {
        // find the first processor and get its parent group id
        Optional<ProcessorDTO> firstProcessor = template.getSnippet().getProcessors().stream().findFirst();
        if (firstProcessor.isPresent()) {
            String groupId = firstProcessor.get().getParentGroupId();
            ProcessGroupDTO snippetGroup = new ProcessGroupDTO();
            snippetGroup.setId(groupId);
            snippetGroup.setParentGroupId(template.getGroupId());
            snippetGroup.setContents(template.getSnippet());
            cache.add(snippetGroup);
        }
    }
    if (groups != null) {
        groups.stream().forEach(group -> cache.add(group));
    }
    // add any remote ProcessGroups
    if (template.getSnippet().getRemoteProcessGroups() != null) {
        template.getSnippet().getRemoteProcessGroups().stream().forEach(remoteProcessGroupDTO -> cache.add(remoteProcessGroupDTO));
    }
    NifiVisitableProcessGroup visitableGroup = getFlowOrder(parentProcessGroup, cache, false);
    NifiFlowProcessGroup flow = new NifiFlowBuilder().build(visitableGroup);
    return flow;
}
Also used : NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) NifiFlowBuilder(com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder) NifiConnectionOrderVisitorCache(com.thinkbiganalytics.nifi.rest.visitor.NifiConnectionOrderVisitorCache) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 8 with ProcessorDTO

use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.

the class LegacyNifiRestClient method stopProcessor.

public void stopProcessor(String processorGroupId, String processorId) {
    ProcessorDTO dto = new ProcessorDTO();
    dto.setId(processorId);
    dto.setParentGroupId(processorGroupId);
    dto.setState(NifiProcessUtil.PROCESS_STATE.STOPPED.name());
    updateProcessor(dto);
}
Also used : ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO)

Example 9 with ProcessorDTO

use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.

the class LegacyNifiRestClient method findProcessorById.

public ProcessorDTO findProcessorById(String processorId) {
    SearchResultsDTO results = search(processorId);
    // log this
    if (results != null && results.getProcessorResults() != null && !results.getProcessorResults().isEmpty()) {
        log.info("Attempt to find processor by id {}. Processors Found: {} ", processorId, results.getProcessorResults().size());
        ComponentSearchResultDTO processorResult = results.getProcessorResults().get(0);
        String id = processorResult.getId();
        String groupId = processorResult.getGroupId();
        ProcessorDTO processorEntity = getProcessor(groupId, id);
        if (processorEntity != null) {
            return processorEntity;
        }
    } else {
        log.info("Unable to find Processor in Nifi for id: {}", processorId);
    }
    return null;
}
Also used : SearchResultsDTO(org.apache.nifi.web.api.dto.search.SearchResultsDTO) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) ComponentSearchResultDTO(org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO)

Example 10 with ProcessorDTO

use of org.apache.nifi.web.api.dto.ProcessorDTO in project kylo by Teradata.

the class LegacyNifiRestClient method updateProcessorProperty.

public void updateProcessorProperty(String processGroupId, String processorId, NifiProperty property) {
    // fetch the processor
    ProcessorDTO processor = getProcessor(processGroupId, processorId);
    // iterate through and update the properties
    // only set this property
    processor.getConfig().getProperties().clear();
    processor.getConfig().getProperties().put(property.getKey(), property.getValue());
    updateProcessor(processor);
}
Also used : ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO)

Aggregations

ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)69 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)24 ArrayList (java.util.ArrayList)21 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)19 ProcessorConfigDTO (org.apache.nifi.web.api.dto.ProcessorConfigDTO)19 HashMap (java.util.HashMap)17 HashSet (java.util.HashSet)16 FlowSnippetDTO (org.apache.nifi.web.api.dto.FlowSnippetDTO)15 PortDTO (org.apache.nifi.web.api.dto.PortDTO)15 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)15 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)13 Map (java.util.Map)11 Response (javax.ws.rs.core.Response)11 ControllerServiceDTO (org.apache.nifi.web.api.dto.ControllerServiceDTO)11 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)11 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)10 List (java.util.List)10 Set (java.util.Set)10 Collectors (java.util.stream.Collectors)9 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)9