Search in sources :

Example 6 with NifiVisitableProcessGroup

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;
}
Also used : NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) NifiFlowBuilder(com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup)

Example 7 with NifiVisitableProcessGroup

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;
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)

Example 8 with NifiVisitableProcessGroup

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;
}
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) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)

Example 9 with NifiVisitableProcessGroup

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;
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)

Example 10 with NifiVisitableProcessGroup

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;
}
Also used : NifiVisitableProcessor(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessor) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ConnectableDTO(org.apache.nifi.web.api.dto.ConnectableDTO)

Aggregations

NifiVisitableProcessGroup (com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup)12 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)8 NifiComponentNotFoundException (com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)6 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)6 NifiVisitableProcessor (com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessor)4 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)4 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)4 NifiFlowProcessGroup (com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup)3 NifiFlowBuilder (com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder)3 NifiConnectionOrderVisitorCache (com.thinkbiganalytics.nifi.rest.visitor.NifiConnectionOrderVisitorCache)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)2 NiFiRestClient (com.thinkbiganalytics.nifi.rest.client.NiFiRestClient)1 NifiFlowVisitor (com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowVisitor)1 NifiVisitableConnection (com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableConnection)1 NifiConnectionUtil (com.thinkbiganalytics.nifi.rest.support.NifiConnectionUtil)1 NifiProcessUtil (com.thinkbiganalytics.nifi.rest.support.NifiProcessUtil)1 NifiConnectionOrderVisitor (com.thinkbiganalytics.nifi.rest.visitor.NifiConnectionOrderVisitor)1