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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations