Support Questions

Find answers, ask questions, and share your expertise
Announcements
We’ve updated our product names and community labels - click here for full details

NiFi + Groovy: how to build "bread crumbs" (PG.Names path from root to processor)?

avatar
New Contributor

Hello!

I'm newbe in NiFi and Groovy.

I found here – "Solved: Re: Get the processor-group name in NIFI flow - Cloudera Community - 213662" (2018) – very interestion solution! Thank @mburgess !!!  

I have related question.

I want to build with Groovy dictionary for every proceccor where key = Proccesor ID, value = "bread crumbs" (full path to processor from root canvas – the string like this "PG1_Name" / "PG2_(Child_of_PG1)_Name" / "PG3_(Child_of_PG2)_Name" .

The quesions are:

  1. How to get list of Process Groups in the root and in Each PG?
  2. How to get list of Processors in Each PG?
  3. How to organize in Groovy cycles for scan PGs?
  4. How to save / read data in/from Groovy dictionary /  NiFi cache?

Thanks in advance for any help and suggestions! 

 

 

1 REPLY 1

avatar
Master Collaborator

Hello @IgorSpryzhkov

Let me see if I can help with your questions: 


1. How to get list of Process Groups in the root and in Each PG?

For this, you may be able to get the information with this API: 

GET /process-groups/{id}/process-groups
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html 
 

2. How to get list of Processors in Each PG?
 
For this one, this other API request may get you the info: 
GET /process-groups/{id}/processors
 

3. How to organize in Groovy cycles for scan PGs?
In NiFi ExecuteScript (Groovy), you can call the API recursively. 
So you should be able order the logic there to fit what you need. 
 

4. How to save / read data in/from Groovy dictionary /  NiFi cache?

You can use any of these options:
- DistributedMapCache (preferred if cluster, can use processors such as PutDistributedMapCache and FetchDistributedMapCache).
- File-based persistence (write JSON file to disk).
- FlowFile attributes (if just passing data).


Regards,
Andrés Fallas
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs-up button.