use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.
the class NifiConnectionOrderVisitor method getConnectionProcessor.
private NifiVisitableProcessor getConnectionProcessor(String groupId, String id) {
NifiVisitableProcessor processor = visitedProcessors.get(id);
if (processor == null) {
if (!this.processorsMap.containsKey(id)) {
// if the current group is not related to this processgroup then attempt to walk this processors processgroup
try {
log.debug("fetch ProcessGroup for getConnectionProcessor {} ", groupId);
ProcessGroupDTO processGroupEntity = getGroup(groupId);
if (processGroupEntity != null) {
ProcessorDTO processorDTO = NifiProcessUtil.findFirstProcessorsById(processGroupEntity.getContents().getProcessors(), id);
if (processorDTO != null) {
this.processorsMap.put(id, processorDTO);
}
if (processGroup.getDto().getId() != groupId && !visitedProcessGroups.containsKey(processGroupEntity.getId())) {
visitProcessGroup(new NifiVisitableProcessGroup(processGroupEntity));
}
} else {
log.error("getConnectionProcessor error. Unable to find Process Group for process group id: {}, and processor: {} {} ", groupId, id);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
//
processor = visitedProcessors.get(id);
if (processor == null) {
processor = new NifiVisitableProcessor(this.processorsMap.get(id));
// visit the group?
processor.accept(this);
}
}
return processor;
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.
the class NifiConnectionOrderVisitor method searchConnectionMatchingDestination.
private ConnectionDTO searchConnectionMatchingDestination(String parentGroupId, String sourceId) {
try {
ProcessGroupDTO parent = null;
try {
parent = getGroup(parentGroupId);
} catch (NifiComponentNotFoundException e) {
log.debug("Exception searching Connection matching the destination. Parent Group ID: " + parentGroupId + ", and destinationId of " + sourceId);
}
if (parent != null) {
// get Contents of this parent
NifiVisitableProcessGroup visitableProcessGroup = new NifiVisitableProcessGroup(parent);
ConnectionDTO conn = visitableProcessGroup.getConnectionMatchingDestinationId(sourceId);
if (conn != null) {
return conn;
}
if (conn == null && parent.getParentGroupId() != null) {
return searchConnectionMatchingSource(parent.getParentGroupId(), sourceId);
}
}
} catch (Exception e) {
log.error("Exception searching Connection matching the destination. Parent Group ID: " + parentGroupId + ", and source of " + sourceId);
}
return null;
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.
the class NifiConnectionOrderVisitor method fetchProcessGroup.
private NifiVisitableProcessGroup fetchProcessGroup(String groupId) {
NifiVisitableProcessGroup group = processGroup;
// fetch it
ProcessGroupDTO processGroupEntity = null;
try {
try {
log.debug("fetchProcessGroup {} ", groupId);
processGroupEntity = getGroup(groupId);
} catch (NifiComponentNotFoundException e) {
log.debug("Unable to find the process group " + groupId);
}
// if the parent is null the parent is the starting process group
if (processGroupEntity != null) {
group = new NifiVisitableProcessGroup(processGroupEntity);
}
} catch (Exception e) {
log.error("Exception fetching the process group " + groupId);
}
return group;
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.
the class AbstractNiFiProcessGroupsRestClientTest method deleteWithRetries.
/**
* Verify deleting a process group.
*/
@Test
public void deleteWithRetries() {
// Mock process group
final ProcessGroupDTO group = new ProcessGroupDTO();
group.setId("d526adec-1f33-463b-8570-e9cf3e6c8703");
group.setParentGroupId("93b1abbb-f805-4f52-8a9e-ffdab224dc44");
// Mock NiFi Process Groups REST client
final AbstractNiFiProcessGroupsRestClient client = Mockito.mock(AbstractNiFiProcessGroupsRestClient.class, Mockito.CALLS_REAL_METHODS);
Mockito.when(client.doDelete(group)).thenThrow(new ClientErrorException(409)).thenReturn(Optional.empty());
// Test delete
Assert.assertEquals(Optional.empty(), client.deleteWithRetries(group, 1, 0, TimeUnit.NANOSECONDS));
}
use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.
the class NifiProcessUtil method getProcessors.
/**
* Return a set of processors in a template, optionally allowing the framework to traverse into a templates input ports to get the connecting process groups
*
* @param template a template to parse
* @param excludeInputs {@code true} will traverse down into the input ports and gather processors in the conencting groups, {@code false} will traverse input ports and their respective process
* groups
* @return return a set of processors
*/
public static Set<ProcessorDTO> getProcessors(TemplateDTO template, boolean excludeInputs) {
Set<ProcessorDTO> processors = new HashSet<>();
for (ProcessorDTO processorDTO : template.getSnippet().getProcessors()) {
processors.add(processorDTO);
}
if (template.getSnippet().getProcessGroups() != null) {
for (ProcessGroupDTO groupDTO : template.getSnippet().getProcessGroups()) {
processors.addAll(getProcessors(groupDTO));
}
}
if (excludeInputs) {
final List<ProcessorDTO> inputs = NifiTemplateUtil.getInputProcessorsForTemplate(template);
Iterables.removeIf(processors, new Predicate<ProcessorDTO>() {
@Override
public boolean apply(ProcessorDTO processorDTO) {
return (inputs.contains(processorDTO));
}
});
}
return processors;
}
Aggregations