use of com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup in project kylo by Teradata.
the class DefaultNiFiFlowVisitorClient method getFeedFlow.
public NifiFlowProcessGroup getFeedFlow(String processGroupId, NifiConnectionOrderVisitorCache cache) {
NifiVisitableProcessGroup visitableGroup = getFlowOrder(processGroupId, cache);
NifiFlowProcessGroup flow = new NifiFlowBuilder().build(visitableGroup);
String categoryName = flow.getParentGroupName();
String feedName = flow.getName();
feedName = FeedNameUtil.fullName(categoryName, feedName);
// if it is a versioned feed then strip the version to get the correct feed name
feedName = TemplateCreationHelper.parseVersionedProcessGroupName(feedName);
flow.setFeedName(feedName);
return flow;
}
use of com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup 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 com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup 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 com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup 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 com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup in project kylo by Teradata.
the class NifiConnectionOrderVisitor method getDestinationProcessors.
public List<NifiVisitableProcessor> getDestinationProcessors(ConnectionDTO connection, boolean getSource) {
ConnectableDTO dest = connection.getDestination();
List<NifiVisitableProcessor> destinationProcessors = new ArrayList<>();
if (dest != null) {
if ("INPUT_PORT".equalsIgnoreCase(dest.getType())) {
boolean isNew = false;
NifiVisitableProcessGroup group = visitedProcessGroups.get(dest.getGroupId());
if (group == null) {
group = fetchProcessGroup(dest.getGroupId());
}
ConnectionDTO conn = group.getConnectionMatchingSourceId(dest.getId());
if (conn != null) {
destinationProcessors = getDestinationProcessors(conn, getSource);
if (getSource) {
List<NifiVisitableProcessor> outputProcessors = getSourceProcessors(connection);
if (outputProcessors != null) {
for (NifiVisitableProcessor outputProcessor : outputProcessors) {
// outputProcessor.setOutputPortId(dest.getId());
currentProcessGroup.addOutputPortProcessor(dest.getId(), outputProcessor);
}
}
}
}
}
if ("REMOTE_INPUT_PORT".equalsIgnoreCase(dest.getType())) {
boolean isNew = false;
// treat this like a Processor for the connection graph
NifiVisitableProcessor processorDto = getRemoteProcessGroupAsVisitableProcessor(dest.getGroupId(), connection.getParentGroupId());
destinationProcessors.add(processorDto);
} else if ("OUTPUT_PORT".equals(dest.getType())) {
boolean isNew = false;
// get parent processgroup connection to input port
NifiVisitableProcessGroup group = visitedProcessGroups.get(dest.getGroupId());
if (group == null) {
group = fetchProcessGroup(dest.getGroupId());
}
ConnectionDTO conn = group.getConnectionMatchingSourceId(dest.getId());
if (conn == null) {
conn = searchConnectionMatchingSource(group.getDto().getParentGroupId(), dest.getId());
}
if (conn != null) {
// get the processor whos source matches this connection Id
List<NifiVisitableProcessor> destinations = getDestinationProcessors(conn, getSource);
if (destinations != null) {
destinationProcessors.addAll(destinations);
}
if (getSource) {
List<NifiVisitableProcessor> outputProcessors = getSourceProcessors(connection);
if (outputProcessors != null) {
for (NifiVisitableProcessor outputProcessor : outputProcessors) {
currentProcessGroup.addOutputPortProcessor(dest.getId(), outputProcessor);
}
}
}
}
} else if ("FUNNEL".equals(dest.getType())) {
List<ConnectionDTO> passThroughConnections = NifiConnectionUtil.findConnectionsMatchingSourceId(currentProcessGroup.getDto().getContents().getConnections(), connection.getDestination().getId());
if (passThroughConnections != null) {
for (ConnectionDTO dto : passThroughConnections) {
ConnectionDTO newConnection = new ConnectionDTO();
newConnection.setId(connection.getSource().getId());
newConnection.setSource(connection.getSource());
newConnection.setDestination(dto.getDestination());
List<NifiVisitableProcessor> destinations = getDestinationProcessors(newConnection, getSource);
if (destinations != null) {
// destinationProcessor.setOutputPortId(dest.getId());
destinationProcessors.addAll(destinations);
}
}
}
} else if ("PROCESSOR".equals(dest.getType())) {
NifiVisitableProcessor destinationProcessor = getConnectionProcessor(dest.getGroupId(), dest.getId());
destinationProcessors.add(destinationProcessor);
}
}
for (NifiVisitableProcessor destinationProcessor : destinationProcessors) {
destinationProcessor.addSourceConnectionIdentifier(connection);
}
return destinationProcessors;
}
Aggregations