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