Search in sources :

Example 6 with NifiFlowProcessGroup

use of com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup in project kylo by Teradata.

the class NifiIntegrationRestController method getFlowForCategoryAndFeed.

@GET
@Path("/flow/feed/{categoryAndFeedName}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the flow of the specified feed.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the flow.", response = NifiFlowProcessGroup.class), @ApiResponse(code = 500, message = "The process group is unavailable.", response = RestResponseStatus.class) })
public Response getFlowForCategoryAndFeed(@PathParam("categoryAndFeedName") String categoryAndFeedName) {
    accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ADMIN_FEEDS);
    NifiFlowProcessGroup flow = legacyNifiRestClient.getFeedFlowForCategoryAndFeed(categoryAndFeedName);
    NifiFlowDeserializer.prepareForSerialization(flow);
    return Response.ok(flow).build();
}
Also used : NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with NifiFlowProcessGroup

use of com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup in project kylo by Teradata.

the class DefaultNiFiFlowVisitorClient method getFeedFlowForCategoryAndFeed.

public NifiFlowProcessGroup getFeedFlowForCategoryAndFeed(String categoryAndFeedName) {
    NifiFlowProcessGroup flow = null;
    String category = FeedNameUtil.category(categoryAndFeedName);
    String feed = FeedNameUtil.feed(categoryAndFeedName);
    // 1 find the ProcessGroup under "root" matching the name category
    ProcessGroupDTO processGroupEntity = restClient.processGroups().findRoot();
    ProcessGroupDTO root = processGroupEntity;
    ProcessGroupDTO categoryGroup = root.getContents().getProcessGroups().stream().filter(group -> category.equalsIgnoreCase(group.getName())).findAny().orElse(null);
    if (categoryGroup != null) {
        ProcessGroupDTO feedGroup = categoryGroup.getContents().getProcessGroups().stream().filter(group -> feed.equalsIgnoreCase(group.getName())).findAny().orElse(null);
        if (feedGroup != null) {
            flow = getFeedFlow(feedGroup.getId());
        }
    }
    return flow;
}
Also used : NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 8 with NifiFlowProcessGroup

use of com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup in project kylo by Teradata.

the class DefaultNiFiFlowVisitorClient method getFeedFlows.

public List<NifiFlowProcessGroup> getFeedFlows(Collection<String> feedNames, final NifiConnectionOrderVisitorCache cache) {
    log.info("get Graph of Nifi Flows looking for {} ", feedNames == null ? "ALL Feeds " : feedNames);
    long start = System.currentTimeMillis();
    List<NifiFlowProcessGroup> feedFlows = new ArrayList<>();
    ProcessGroupDTO processGroupEntity = restClient.processGroups().findRoot();
    ProcessGroupDTO root = processGroupEntity;
    // first level is the category
    root.getContents().getProcessGroups().stream().sorted(new Comparator<ProcessGroupDTO>() {

        @Override
        public int compare(ProcessGroupDTO o1, ProcessGroupDTO o2) {
            if (TemplateCreationHelper.REUSABLE_TEMPLATES_PROCESS_GROUP_NAME.equalsIgnoreCase(o1.getName())) {
                return -1;
            }
            if (TemplateCreationHelper.REUSABLE_TEMPLATES_PROCESS_GROUP_NAME.equalsIgnoreCase(o2.getName())) {
                return -1;
            }
            return o1.getName().compareTo(o2.getName());
        }
    }).forEach(category -> {
        for (ProcessGroupDTO feedProcessGroup : category.getContents().getProcessGroups()) {
            // second level is the feed
            String feedName = FeedNameUtil.fullName(category.getName(), feedProcessGroup.getName());
            // if it is a versioned feed then strip the version to get the correct feed name
            feedName = TemplateCreationHelper.parseVersionedProcessGroupName(feedName);
            // if feednames are sent in, only add those that match or those in the reusable group
            if ((feedNames == null || feedNames.isEmpty()) || (feedNames != null && (feedNames.contains(feedName) || TemplateCreationHelper.REUSABLE_TEMPLATES_PROCESS_GROUP_NAME.equalsIgnoreCase(category.getName())))) {
                NifiFlowProcessGroup feedFlow = getFeedFlow(feedProcessGroup.getId(), cache);
                feedFlow.setFeedName(feedName);
                feedFlows.add(feedFlow);
            }
        }
    });
    long end = System.currentTimeMillis();
    log.info("finished Graph of Nifi Flows.  Returning {} flows, {} ", feedFlows.size(), (end - start) + " ms");
    return feedFlows;
}
Also used : NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) ArrayList(java.util.ArrayList) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) Comparator(java.util.Comparator)

Example 9 with NifiFlowProcessGroup

use of com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup 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 10 with NifiFlowProcessGroup

use of com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup in project kylo by Teradata.

the class NifiFlowBuilder method build.

/**
 * Build the {@link NifiFlowProcessGroup} from the visited {@link NifiVisitableProcessGroup} returning the simplified graph of objects that make up the flow
 *
 * @param group the visited process group and its flow connecting processors together
 * @return the simplified graph representing the flow starting with the supplied visited process group
 */
public NifiFlowProcessGroup build(NifiVisitableProcessGroup group) {
    NifiFlowProcessGroup flowProcessGroup = toFlowProcessGroup(group);
    flowProcessGroup.setProcessorMap(cache);
    flowProcessGroup.addConnections(group.getConnections());
    ProcessGroupDTO groupDTO = group.getParentProcessGroup();
    if (groupDTO != null) {
        flowProcessGroup.setParentGroupId(groupDTO.getId());
        flowProcessGroup.setParentGroupName(groupDTO.getName());
    }
    flowProcessGroup.assignFlowIds();
    return flowProcessGroup;
}
Also used : NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Aggregations

NifiFlowProcessGroup (com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup)11 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)5 NifiFlowBuilder (com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder)3 NifiVisitableProcessGroup (com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup)3 ReusableTemplateConnectionInfo (com.thinkbiganalytics.feedmgr.rest.model.ReusableTemplateConnectionInfo)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 ArrayList (java.util.ArrayList)2 PortDTO (org.apache.nifi.web.api.dto.PortDTO)2 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)2 TemplateConnectionUtil (com.thinkbiganalytics.feedmgr.nifi.TemplateConnectionUtil)1 NifiFlowCache (com.thinkbiganalytics.feedmgr.nifi.cache.NifiFlowCache)1 PortDTOWithGroupInfo (com.thinkbiganalytics.feedmgr.rest.model.PortDTOWithGroupInfo)1 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)1 RegisteredTemplateRequest (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplateRequest)1 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)1 StreamingFeedJmsNotificationService (com.thinkbiganalytics.feedmgr.service.feed.StreamingFeedJmsNotificationService)1 SecurityService (com.thinkbiganalytics.feedmgr.service.security.SecurityService)1 ImportTemplate (com.thinkbiganalytics.feedmgr.service.template.importing.model.ImportTemplate)1 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)1